Static evalution of casts on literals #20

Merged
HEL merged 7 commits from feat/literal-static-constraints into main 2026-06-24 09:32:55 +00:00
Owner

This PR enables the Python type checker to statically evaluate cast expressions on literal values.
To do so, it adds an Evaluator class which can evaluate custom Python AST expressions given some literal value.
That could have also been implemented using Python's own eval machinery, but I prefer to have control on how things are evaluated and what is available in the context.

Finally, cast expressions which have been fully evaluated statically do not generate runtime assertions as this would be redundant.

This PR enables the Python type checker to statically evaluate cast expressions on literal values. To do so, it adds an `Evaluator` class which can evaluate custom Python AST expressions given some literal value. That could have also been implemented using Python's own `eval` machinery, but I prefer to have control on how things are evaluated and what is available in the context. Finally, cast expressions which have been fully evaluated statically do not generate runtime assertions as this would be redundant.
HEL self-assigned this 2026-06-24 09:32:49 +00:00
HEL added 7 commits 2026-06-24 09:32:49 +00:00
HEL merged commit 252a5abdfd into main 2026-06-24 09:32:55 +00:00
HEL deleted branch feat/literal-static-constraints 2026-06-24 09:32:55 +00:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: HEL/midas#20