Add 3.12 typing features to the compiler #5302
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is the first step towards implementing 3.12 compliant typing(#5252 ) . It's taken me a long time to get this far so I wanted to check in before spending more time building on this foundation.
Changes made:
_typing
stdlib module. This will eventually replace the fundamental typing primitives that are currently implemented intyping.py
. This is still very much a work in progress, but it works well enough to exercise the new compiler features.def foo[X](x: X): ...
)class C[X]: def __init__(x: X): ...
)type X = list[int]
)Some questions:
push_symbol_table
andpop_symbol_table
are my attempt to simulate the behavior of the new Annotation Scopes. I'm not sure if I got this 100% right.CALL_INTRINSIC_1
andCALL_INTRINSIC_2
that do weird fundamental python things like printing, importing, or defining types. It seems to me that this is mostly a way of organizing the code than a fundamental design requirement, so I ignored this and added the intrinsics I needed as instructions. Perhaps this is not correct?