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

refactor[next]: Use type specification for itir.Literal #1529

Merged

Conversation

tehrengruber
Copy link
Contributor

@tehrengruber tehrengruber commented Apr 15, 2024

Small PR in preparation of the new ITIR type system. Currently the type of a itir.Literal is stored as a string which blocks introducing a type: ts.TypeSpecification attribute in all itir.Nodes. In order to keep the PR for the new type inference easy to review this has been factored out.

class Literal(Expr):
    value: str
    type: str

    @datamodels.validator("type")
    def _type_validator(self: datamodels.DataModelTP, attribute: datamodels.Attribute, value):
        if value not in TYPEBUILTINS:
            raise ValueError(f"'{value}' is not a valid builtin type.")

is changed to

class Literal(Expr):
    value: str
    type: ts.ScalarType

@tehrengruber tehrengruber requested a review from egparedes April 15, 2024 06:01
Copy link
Contributor

@egparedes egparedes left a comment

Choose a reason for hiding this comment

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

Minor suggestions to but overall, it looks good. I won't need another review so I'm approving the PR now but please don't forget to fix them.

@tehrengruber tehrengruber merged commit 9f44142 into GridTools:main Apr 17, 2024
31 checks passed
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

Successfully merging this pull request may close these issues.

2 participants