kengorab/abra-lang

Referencing types out of lexical order

Closed this issue · 0 comments

The following code will fail (at the typechecking layer):

type Foo {
  func a(self): Int = Bar().b() + 1
}

type Bar {
  func b(self): Int = 5
}

Foo().a()

This fails because, even though we've scouted ahead and seen the Bar type, we don't yet have a TypeDecl node for it (which is how we obtain its field information for invocation). This should work.

Note that in order for this to work, I will also have to hoist type/enum declarations in scopes as well (though I think for now we should still limit type/enum declaration to the root scope).