Open dlunde opened 2 years ago
Maybe related: syn
s can escape their language fragment and be used in top-level type declarations:
type MyType = MySyn
lang MyLang
syn MySyn =
| Syn {}
end
mexpr
use MyLang in
let s: MyType = Syn {} in
()
This program passes the type checking, and the pure MExpr code looks like this:
$ mi compile --test --keep-dead-code --typecheck --debug-parse temp.mc
type MySyn =
<>
in
type MyType =
MySyn
in
con MyLang_Syn: (()) -> (MySyn) in
let s: MyType =
MyLang_Syn
{}
in
{}
I found the source of the "syn
s escaping their fragment" issue: https://github.com/miking-lang/miking/blob/4ccffe8e9775f384696416ffe53582581888f8aa/src/boot/lib/mlang.ml#L933-L942
We just insert all syn
types at the beginning of the program and do no mangling, whereby the early uses end up ok. In general this means that all syn
types are global, and (probably?) always shadowed by other types. I suspect that's not the semantics we'd ideally want, but it's easier than something more proper, and I don't think we've quite specified what the semantics should be.
I suspect the whole mlang thing could use a bit of an overhaul with what we've learned, but probably better to do that when we go towards full selfhosting.
The program
gives the type error
@larshum looked into this and wrote the following: