[fine] Improvements to classes

- Classes are defined lazily
- Member access is via environment
- Member access is just a binary expression with a weird environment
- Slot loads look like variable loads now
- Associativity in the parser (ugh)
This commit is contained in:
John Doty 2024-01-22 23:17:02 -08:00
parent 0d48bfb113
commit 2839b43f6d
5 changed files with 286 additions and 123 deletions

View file

@ -0,0 +1,18 @@
class Foo {
foo: f64;
}
fun test() {
let f = new Foo { foo: 12 };
let z = f.{let y = 222; foo };
}
// NOTE: The AST allows for generic expressions to the right of the dot.
// We need to make sure things are parsed correctly.
//
// TODO: Better parser recovery will improve the specifics of the errors.
// @expect-errors:
// | 7:12: Error at '{': expected an expression
// | 7:13: Error at 'let': expect ';' to end a let statement
// | 7:26: cannot find value foo here
// | 8:0: Error at '}': unbalanced '}'