Skip to content

support parsing discard in place of _forget #1644

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
May 9, 2023

Conversation

kavon
Copy link
Member

@kavon kavon commented May 8, 2023

SE-390 concluded with choosing the keyword discard rather than forget. This commit begins the process of deprecating the old keyword on the swift-syntax side.

rdar://108859077

SE-390 concluded with choosing the keyword `discard` rather than
`forget`. This commit begins the process of deprecating the old
keyword on the swift-syntax side.

rdar://108859077
@kavon kavon requested a review from ahoppen as a code owner May 8, 2023 23:06
@kavon
Copy link
Member Author

kavon commented May 8, 2023

@swift-ci please test

@kavon kavon enabled auto-merge May 8, 2023 23:28
@kavon kavon merged commit fcc4880 into swiftlang:main May 9, 2023
Copy link
Member

@ahoppen ahoppen left a comment

Choose a reason for hiding this comment

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

I’ve got two minor code style comments. Could you address them in a follow-up PR?

Comment on lines +127 to +130
case (.forgetKeyword, let handle)?: // NOTE: support for deprecated _forget
fallthrough
case (.discardKeyword, let handle)?:
return label(self.parseDiscardStatement(discardHandle: handle), with: optLabel)
Copy link
Member

Choose a reason for hiding this comment

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

The more swifty way to do write this would be

Suggested change
case (.forgetKeyword, let handle)?: // NOTE: support for deprecated _forget
fallthrough
case (.discardKeyword, let handle)?:
return label(self.parseDiscardStatement(discardHandle: handle), with: optLabel)
case (.forgetKeyword, let handle)?,
(.discardKeyword, let handle)?:
return label(self.parseDiscardStatement(discardHandle: handle), with: optLabel)

Comment on lines +1016 to +1018
case .forgetKeyword?: // NOTE: support for deprecated _forget
fallthrough
case .discardKeyword?:
Copy link
Member

Choose a reason for hiding this comment

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

Same here. fallthrough is discouraged in Swift

Suggested change
case .forgetKeyword?: // NOTE: support for deprecated _forget
fallthrough
case .discardKeyword?:
case .discardKeyword?, .forgetKeyword?: // NOTE: support for deprecated _forget

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.

2 participants