-
Notifications
You must be signed in to change notification settings - Fork 78
Description
#2748 modified SAWScript parsing in a way that allowed users to write previously-syntactically-invalid types, like Int Int. SAWScript currently fails to reject such a type as ill-kinded. SAW even allows values of such types to be constructed without resorting to undefined:
sawscript> let x : Int Int = return 0
sawscript> :t x
Int Int
sawscript> print x
[17:05:52.428] return 0
sawscript>
More comprehensive kind-checking ought to put a stop to this.
In terms of code, note that a fix for this may go hand in hand with substantially reworking or removing the BlockCon AST node, into which all type constructor applications are currently parsed and through which kind-checking flows. Several notes (authored by @sauclovian-g in #2157) suggest that BlockCon ought to be removed outright:
saw-script/saw-script/src/SAWScript/Typechecker.hs
Lines 1786 to 1789 in e9844d6
| -- XXX: while BlockCon exists, ContextCon has kind * and you | |
| -- have to use BlockCon to paste a result type to a ContextCon. | |
| -- (BlockCon should be removed. Then ContextCon has kind * -> * | |
| -- like you'd expect.) |
| -- XXX special case for BlockCon (remove along with BlockCon) |
saw-script/saw-script/src/SAWScript/Typechecker.hs
Lines 1951 to 1953 in e9844d6
| -- position associated with the monad context. (This part is a | |
| -- result of BlockCon existing and can go away when BlockCon is | |
| -- removed.) |
Note also that (I believe) this issue encompasses much of the "other cleanup" referred to in #2163.