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

Add diagnostic to verify the left hand side of a generic constraint. #5112

Merged
merged 3 commits into from
Sep 20, 2024

Conversation

csyonghe
Copy link
Collaborator

@csyonghe csyonghe commented Sep 19, 2024

(This PR is based on top of PR #5111.)

Add validation on left hand side of type generic. For example, we need to diagnose an error for:

void foo<T>() where int : X {} // int cannot be left hand side of a generic constraint.

Closes #5113.

@csyonghe csyonghe added the pr: non-breaking PRs without breaking changes label Sep 19, 2024
jkwak-work
jkwak-work previously approved these changes Sep 20, 2024
Copy link
Collaborator

@jkwak-work jkwak-work left a comment

Choose a reason for hiding this comment

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

Looks good to me.

// associatedtype T
// where T : IFoo // OK, constraint is on the associatedtype T itself.
// where T.T == X; // OK, constraint is on the associated type of T.
// where int == X; // Error, int is not a valid left hand side of a constraint.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think you meant to say

where int : X // Error ...

I mean that == should be replaced with : and ; should be dropped.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

== is also a valid constraint operator, for type equality constraints.

@csyonghe csyonghe merged commit b4c851f into shader-slang:master Sep 20, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr: non-breaking PRs without breaking changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add validation of left side of where clause.
2 participants