Open jswrenn opened 6 years ago
Thanks for reporting. That's frustrating and kind of silly. The type-checker hasn't yet figured out the intersection of shared fields when type-checking variants' methods, so it doesn't know that all Foo
s have a bar
yet.
If you need a workaround, this will type-check if you omit the Foo
annotation; the type-checker has special handling for self
in when checking methods of a datatype. Maybe it should just be a well-formedness error to annotate self
.
Note also that later in the program, one can write:
fun f(x :: Foo): x.bar end
later, it will type-check. This is a problem somewhat specific to the body of a variant.
This program:
...produces the error: