Skip to content

Conversation

ahoppen
Copy link
Member

@ahoppen ahoppen commented Oct 17, 2025

I think the guard is a lot easier to read here, noticed while reviewing #3171.

@ahoppen
Copy link
Member Author

ahoppen commented Oct 17, 2025

@swift-ci Please test

@ahoppen
Copy link
Member Author

ahoppen commented Oct 17, 2025

@swift-ci Please test macOS

rintaro
rintaro previously approved these changes Oct 17, 2025
Copy link
Contributor

@bnbarham bnbarham left a 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 🤷


// If we don't have attributes, then it cannot be an accessor block.
if nextToken.rawTokenKind != .atSign {
guard self.at(.atSign) else {
Copy link
Member

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.

Copy link
Member Author

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.

@rintaro rintaro dismissed their stale review October 17, 2025 16:55

Misapproved

I think the guard is a lot easier to read here, noticed while reviewing swiftlang#3171.
get
var x: Int = 2
{
@something
Copy link
Member Author

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.

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.

3 participants