Annotate AST nodes with inferred types #990
Labels
C-Project
A larger project, more suitable for experienced contributors.
L-Type inference
The process of inferring the type of a Swarm expression.
S-Moderate
The fix or feature would substantially improve user experience.
Z-Feature
A new feature to be added to the game.
Z-Refactoring
This issue is about restructuring the code without changing the behaviour to improve code quality.
Is your feature request related to a problem? Please describe.
While performing type inference, we recurse through the AST, inferring a type for each node. Currently we throw away all this intermediate information and return only the top-level inferred type for an entire AST. However, there are many situations where having this intermediate type information would be helpful, for example, to help with things like LSP hover hints, or to apply type-specific elaboration.
Describe the solution you'd like
Rather than simply returning a type, the type inference engine should return a new AST annotated with a type at every node. We already have a
SrcLoc
at every node via theSyntax
wrapper type, so this would just require adding a new type field toSyntax
.I have started on implementing this in the https://github.com/swarm-game/swarm/tree/annotate-ast branch. Rewriting the elaboration code is proving tricky but if I bang my head against it a bit more I think I will get it.
The text was updated successfully, but these errors were encountered: