I'm having fun writing a simple type checker, but I'm learning firsthand why syntax-directed checking doesn't work. It prevents inference.
My checker catches real bugs, but it can't handle cases like this:
[1, 2].map(fun(x) { x + 1; })
I think I need bidirectional checking.
Related Posts
@tristanC That's an option! There's often cases where you know what the user wanted though, so you can provide a sensible AST that the toolchain can handle.
For example, a malformed string literal can still be parsed a string so type checking etc can be helpful.
Do any tech streamers try new software live? It'd be a really fun way of doing UX testing.
I'm changing method definition syntax in my language:
// old
fun (this: Int) inc(): Int { this + 1 }
// new
method inc(this: Int): Int { this + 1 }
The original syntax was inspired by Go, but the new syntax is more grep-friendly and perhaps more readable. Not sure about the verbosity though. Thoughts?