Skip to content

Investigate randomly failing non-null checks #1139

Closed
@dcodeIO

Description

@dcodeIO

While working on #1129 I noticed that flows and/or assignments do sometimes not correctly pick up non-null state after assigning to a local from a function call in a conditional branch:

      if (tn.skip(Token.COLON)) {
        type = this.parseType(tn);
        if (!type) return null;
      } else {
        type = Node.createOmittedType(tn.range(tn.pos)); // returns non-null
        type = type!; // FIXME: WHY?
      }
      // otherwise type is considered nullable here leading to follow-up errors
     someFuncWantingNonNullable(type); // cannot assign Type | null to Type

There are 8 code locations in the compiler currently with that FIXME: WHY? comment that all look similar, but I didn't yet manage to reproduce this in a smaller code sample. If someone else manages to, that would be super helpful :)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions