Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #256, Improve checking for null type #263

Merged
merged 1 commit into from
Oct 22, 2015
Merged

Fix #256, Improve checking for null type #263

merged 1 commit into from
Oct 22, 2015

Commits on Oct 21, 2015

  1. Improve checking for null type

    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 auxilary
    function `typecheckNotNull` which is called when an expression is used
    where 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
    ```
    def foo() : Foo{
      let x = 42 in
        while x < 0 {
          x = x - 1;
          null;
        }
      }
    ```
    we know that the `null` should be a `Foo` from the result type.
    EliasC committed Oct 21, 2015
    Configuration menu
    Copy the full SHA
    f927720 View commit details
    Browse the repository at this point in the history