-
Notifications
You must be signed in to change notification settings - Fork 459
Minor cleanup from if
to guard
statement
#3172
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
base: main
Are you sure you want to change the base?
Conversation
@swift-ci Please test |
@swift-ci Please test macOS |
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.
Personally I find if !self.at(.atSign)
easier and generally just use guard for introducing new variables, but 🤷
Sources/SwiftParser/Lookahead.swift
Outdated
|
||
// If we don't have attributes, then it cannot be an accessor block. | ||
if nextToken.rawTokenKind != .atSign { | ||
guard self.at(.atSign) else { |
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.
Ah sorry, nextToken
is peek()
. This is a behavior change.
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.
Great catch, I guess this shows why at
and peek(isAt:)
are more explicit. Added a test case for this.
I think the guard is a lot easier to read here, noticed while reviewing swiftlang#3171.
get | ||
var x: Int = 2 | ||
{ | ||
@something |
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.
@rintaro Do you have an idea what kind of attribute would make sense here, I can’t think of anything.
I think the guard is a lot easier to read here, noticed while reviewing #3171.