Fix #256, Improve checking for null type #263
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This commit should fix most cases where the null type leaks to the
backend (which causes a crash) by catching it in the typechecker
instead. It generalizes checking for
null
by introducing an auxilaryfunction
typecheckNotNull
which is called when an expression is usedwhere no additional type information could coerce the null type to a
reference type (for example the right hand sides of the declarations of
a let or the body of a closure). It unifies all earlier error messages
of type "Cannot infer type of null valued expression".
It's usage is not always obvious. For example, when typechecking a
sequence, all expressions but the last should be checked for the null
type, but the last one should not, as it's actual type could be inferred
from the context of the sequence.
There is also added support for propagating an inferred result type. For
example, in the function
we know that the
null
should be aFoo
from the result type.