Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core: add TypeVarConstraint, and use in irdl_to_attr_constraint #3443

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

superlopuh
Copy link
Member

@superlopuh superlopuh commented Nov 13, 2024

We currently do not preserve type var information in the ParamDef, meaning that each time that we construct a constraint that specialises a TypeVar used in the definition of an attribute, we reconstruct the definition from scratch. Currently, this means re-parsing the type hints used when defining the attribute, but with a dictionary that maps the TypeVar used to the concrete constraint to use for the attribute's parameter. In order to move away from the type-based ParamDef pattern of defining parametrized attributes, we need to somehow store the information of TypeVars used in the attribute definition. This PR proposes a mechanism based on a new kind of attribute constraint, and uses it to split the existing mechanism into two phases: first constructing the constraint with TypeVars, and then swapping out the TypVars in the result. Upcoming PRs will remove the part where we remove the type parsing for each time that a new constraint for a ParametrizedAttribute is constructed.

@superlopuh superlopuh added the core xDSL core (ir, textual format, ...) label Nov 13, 2024
@superlopuh superlopuh self-assigned this Nov 13, 2024
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

Copy link

codecov bot commented Nov 13, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.31%. Comparing base (d9e2fa1) to head (55bd6aa).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3443      +/-   ##
==========================================
- Coverage   90.33%   90.31%   -0.02%     
==========================================
  Files         464      464              
  Lines       58076    58215     +139     
  Branches     5552     5555       +3     
==========================================
+ Hits        52463    52577     +114     
- Misses       4184     4210      +26     
+ Partials     1429     1428       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


🚨 Try these New Features:

@alexarice
Copy link
Collaborator

What was the status on this? Is this still the approach we want to take?

@superlopuh
Copy link
Member Author

I'm feeling a bit stuck... There are a few problems still remaining, one of which is that I couldn't hack the whole lazy get/set tyoe variable, so we may have to deal with this as a temporary measure. The other problem is with the type system, where it seems like for this to really make sense we would need to ask all clients to enable experimental Pyright type checking. I had a chat with Mathieu and he is fine with this, I'll raise this at the xDSL meeting this afternoon. I've also not yet completed the migration to param_def in my topmost branch, so will have to check what other functionality is missing before opening this all up for a proper discussion. I'm giving myself until the end of the year to figure this out, if that's OK with everyone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core xDSL core (ir, textual format, ...)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants