[asl] maintain a type annotation for every typechecked expression#1870
[asl] maintain a type annotation for every typechecked expression#1870Roman-Manevich wants to merge 2 commits into
Conversation
a8097cc to
124b7b9
Compare
HadrienRenaud
left a comment
There was a problem hiding this comment.
I think this needs to be more carefully documented. For example one of the important thing that is not said is that none of those type informations are used for type-checking.
Another important choice made here is not to use dependent types for some constructed expressions. This needs to be justified. I can see other options:
- Do not put any type annotations for those.
- Put only integer, as is done here
- Use recursive values to provide full precision types for literal values (this seems dangerous to me).
Maybe this should be hidden behind a command line flag not to impact the reference interpreter.
In the long term, we should probably write a typed AST which would incorporate those informations, and document what precision is given by those.
124b7b9 to
df82466
Compare
There was a problem hiding this comment.
I think we need to reduce the scope of this PR. I think it should contain only:
- Mechanism for storing type annotations - whether the existing version or Hadrien's proposal.
- Storing type annotations as calculated during type-checking already (i.e. wrap
annotate_{expr,lexpr},base_value)
I.e. the additional type annotations not provided by the type system, the exhaustivity checks should be removed. In future we can discuss whether we consider "missing" type annotations as truly missing (and if so whether they should be inserted post-hoc or the type system should be changed to calculate them appropriately), and how this could all be encoded into a truly typed AST.
Please let me know if you disagree.
df82466 to
52ba579
Compare
… an extra annotation
52ba579 to
a8157e8
Compare
55e915d to
c1688c4
Compare
HadrienRenaud
left a comment
There was a problem hiding this comment.
This looks good to me, thanks @Roman-Manevich, I've just got a few improvements.
Co-authored-by: Hadrien Renaud <hadrien.renaud2@arm.com>
c1688c4 to
37f89ee
Compare
This PR enables maintaining the type inferred for each expression during typechecking as an annotation attached to the expression. The intention is to make this available for tools built on top of
aslref.