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

Field shadowing and parametrized attributes (op.name/attr.name) #98

Closed
webmiche opened this issue Apr 1, 2022 · 3 comments
Closed

Field shadowing and parametrized attributes (op.name/attr.name) #98

webmiche opened this issue Apr 1, 2022 · 3 comments

Comments

@webmiche
Copy link
Collaborator

webmiche commented Apr 1, 2022

The following breaks with a Exception 1 parameters expected, got 0:

@irdl_attr_definition
class Foo(ParametrizedAttribute):
  name: str = "bar.foo"
  param = ParameterDef(AnyAttr())

# Try to construct
Foo([*SomeAttr*])

Removing the type annotation for the name field fixes it:

@irdl_attr_definition
class Foo(ParametrizedAttribute):
  name = "bar.foo"
  param = ParameterDef(AnyAttr())

# Try to construct
Foo([*SomeAttr*])

I think we should change the API s.t. names are not defined as fields. That would make it less error-prone. Maybe have the name of the Attribute as part of the decorator? irdl_attr_definition("bar.foo")

@math-fehr
Copy link
Collaborator

Yeah, you are probably right! Alternatively, we could just return an error whenever we have fields that are not definitions, or name

@superlopuh superlopuh changed the title Field shadowing and parametrized attributes Field shadowing and parametrized attributes (op.name/attr.name) Mar 14, 2023
@superlopuh
Copy link
Member

Update title for easier search

@math-fehr
Copy link
Collaborator

This has since been fixed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants