Summary

[types] Enforce parameter types on specialization

Metadata

Description

Currently no enforcing happens if specialization takes place.

Here's a case from scrutiny-tests. Note that scheme#+ has a specialization for parameters (* *). When using `-A` flag no specialization takes place, so the enforcing happens.

In this example you'd like to have the type for `x` to be enforced to `number` after the `if`.

 ;; noreturn conditional branch enforces "number" on x
 (define (foo2 x)
   (if (string? x) (error "foo") (+ x 3))
   (string-append x "abc"))
 
 ;; $ csc -O3 enforce-fail.scm
 ;;
 ;; Warning: in toplevel procedure `foo2':
 ;;   (enforce-fail.scm:7) in procedure call to `scheme#string-append', expected argument #1 of type `string' but was given an argument of type `(not string)'
 
 ;; $ csc -A enforce-fail.scm
 ;;
 ;; Warning: in toplevel procedure `foo2':
 ;;   (enforce-fail.scm:7) in procedure call to `scheme#string-append', expected argument #1 of type `string' but was given an argument of type `number'