coalton-lang / coalton

Coalton is an efficient, statically typed functional programming language that supercharges Common Lisp.
https://coalton-lang.github.io/
MIT License
1.12k stars 67 forks source link

fix translate-expression for node-for #1199

Closed stylewarning closed 1 month ago

stylewarning commented 1 month ago

This PR fixes two bugs, #1197 and #1200

1197 was caused by incorrect types being assigned to the resulting translated node-for in translate-expression. I think this was just human mistake in constructing a somewhat complicated AST node with lots of sub-nodes. I believe I have it correct, but I'm not 100% confident. (It does pass a new test I added.) Is there a better way to do it?

1200 was problematic because all looping constructs implicitly returned cl:nil, but the type checker unified loops to Unit. I've changed all of the loops to just explicitly codegen a Unit return.