Skip to content

[Typechecker] Diagnose use of magic literals as raw value for enum case #32364

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

Merged
merged 1 commit into from
Jun 15, 2020
Merged

[Typechecker] Diagnose use of magic literals as raw value for enum case #32364

merged 1 commit into from
Jun 15, 2020

Conversation

theblixguy
Copy link
Collaborator

We don't support use of magic literals like #file or #line as raw values for an enum case. At the moment, the compiler simply crashes when it comes across such literals. I think we can support them but that involves a bit more work so for now let's just diagnose them as unsupported instead of crashing the compiler.

Resolves SR-12998

@theblixguy theblixguy requested a review from CodaFi June 13, 2020 18:09
@theblixguy
Copy link
Collaborator Author

@swift-ci please smoke test

Copy link
Contributor

@CodaFi CodaFi left a comment

Choose a reason for hiding this comment

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

I'll take this over a crash, but could you test more kinds of literals?

Copy link
Contributor

@xedin xedin left a comment

Choose a reason for hiding this comment

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

LGTM!

@theblixguy
Copy link
Collaborator Author

I have added a few more test cases (including a test for object literals). Should I cherry-pick this to 5.3 too?

@swift-ci please test

@CodaFi
Copy link
Contributor

CodaFi commented Jun 15, 2020

Thanks for the tests. I don't think this needs to go into 5.3.

@swift-ci please smoke test

@swift-ci

This comment has been minimized.

@swift-ci

This comment has been minimized.

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.

4 participants