Open Collective
Open Collective
Loading
'let' typing rule
Published on July 24, 2021 by Ambrose Bonnaire-Sergeant

Hi Patrons,

I've merged a typing rule for the clojure.core/let macro. In terms of its construction, it's a somewhat like the 'for' rule from the last post, while also needing to infer and propagate the :tag for each binding--still, it was still quite a challenge and took an additional several months.

Since almost every test in typedclojure expands to 'let', I have a pretty good idea that the typing rule is working as well as the previous approach (which is to expand it to 'let*').

There are several directions to go from here:
1. I can now improve static type error messages involving destructuring to be more helpful, since I have complete control of what is being checked (before, I was at the mercy of 'destructure'). So, instead of "foo___auto#1 is not a Set", think something like "foo from destructuring [{foo :bar}] should be a Set, but actually Vector".
2. Add typing rules for other destructuring macros (eg., 'fn', 'doseq') to improve their error messages.

Anyway, I think this is another cause for celebration, as this is the culmination of 3+ years' work.

Thanks!
Ambrose