-
Notifications
You must be signed in to change notification settings - Fork 439
[SE-0458] Implement "unsafe" effect for the for-in loop #2971
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
Conversation
@swift-ci please test |
@swift-ci please test Linux |
@swift-ci please test |
1 similar comment
@swift-ci please test |
@swift-ci please test macOS |
@swift-ci please test Windows |
lexeme: self.currentToken, | ||
experimentalFeatures: self.experimentalFeatures | ||
), modifierKeyword == .unsafe, !self.peek(isAt: .keyword(.in)) { | ||
unsafeKeyword = self.consumeAnyToken(remapping: .keyword) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we also need to check at least for :
to make sure the following continues to parse:
for unsafe: Int in [1, 2] {
print(unsafe)
}
Also, I’d prefer to do self.expect(.keyword(.unsafe))
instead of consumeAnyToken
. It just adds more context to what kind of keyword unsafeKeyword
is and another layer of safety if the current token should not be unsafe
for any reason in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hah, I read your comments out of order. We indeed need to deal with the :
. Thanks for the self.expect(.keyword(.unsafe))
hint.
assertParse( | ||
"for try await unsafe in e { }", | ||
experimentalFeatures: [.unsafeExpression] | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you also add a test for for unsafe in e { }
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. There's another ambiguity I also need to check for, i.e., for unsafe: Int in e { }
needs to not parse as the unsafe
keyword.
@ahoppen I'll address your comments in a follow-up PR, because I want to get the bones of this in place for the compiler PR to land |
Code review comments addressed via #2977 |
No description provided.