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: (irdl) ParamAttrConstraint can infer recursively #3477

Merged
merged 2 commits into from
Nov 20, 2024

Conversation

superlopuh
Copy link
Member

This seems to work, is there any reason not to do this?

Note: conflicts with #3456

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

codecov bot commented Nov 19, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.29%. Comparing base (d3647b2) to head (8afe11e).
Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3477      +/-   ##
==========================================
+ Coverage   90.26%   90.29%   +0.02%     
==========================================
  Files         461      462       +1     
  Lines       57807    57881      +74     
  Branches     5565     5564       -1     
==========================================
+ Hits        52180    52261      +81     
+ Misses       4190     4187       -3     
+ Partials     1437     1433       -4     

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


🚨 Try these New Features:

Copy link
Collaborator

@alexarice alexarice left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't believe this is sound, ParamAttrConstraint only specifies the base class of the attribute and so could theoretically this could infer the wrong subclass?

@alexarice
Copy link
Collaborator

Note that I'm not sure if being able to capture subclasses is part of the intended semantics of BaseAttr and ParamAttrConstraint, and this might just be an artifact of using python's isinstance

@superlopuh
Copy link
Member Author

Ah yes, although I'm still not sure that we should officially support the whole class hierarchy thing. The error scenario here is that the user specifies a superclass in the constraint and there's a crash at runtime if the superclass is abstract? To avoid this, we could probably check that the class has a name field?

@alexarice
Copy link
Collaborator

Could do an is_runtime_final check?

@alexarice
Copy link
Collaborator

A similar question to this is whether a BaseAttr applied to a type with no parameters should be inferable

Copy link
Collaborator

@math-fehr math-fehr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I either forgot to do this, or at the time is_runtime_final didn't exist yet!
So yeah that looks good to me!

@math-fehr
Copy link
Collaborator

A similar question to this is whether a BaseAttr applied to a type with no parameters should be inferable

Yes it should! What we could do is write an optimization to "convert" a BaseAttr with a singleton type to an EqType, that would also work!

@superlopuh superlopuh merged commit 256a625 into main Nov 20, 2024
15 checks passed
@superlopuh superlopuh deleted the sasha/misc/param-attr-inference branch November 20, 2024 08:19
alexarice added a commit that referenced this pull request Nov 20, 2024
EdmundGoodman pushed a commit to EdmundGoodman/xdsl that referenced this pull request Dec 6, 2024
)

This seems to work, is there any reason not to do this?
EdmundGoodman pushed a commit to EdmundGoodman/xdsl that referenced this pull request Dec 6, 2024
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.

3 participants