Skip to content

[Refactoring] Don't crash when converting a function to async that contains a call to init #37652

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 1, 2021

Conversation

ahoppen
Copy link
Member

@ahoppen ahoppen commented May 26, 2021

We were trying to retrieve the name of all function calls in the body using getBaseIdentifier. But calls to init don’t have a base identifier, just a DeclBaseName (which is special). Work with the DeclBaseName internally to prevent the crash.

Fixes rdar://78024731 [SR-14637]

@ahoppen ahoppen requested a review from bnbarham May 26, 2021 13:50
@ahoppen
Copy link
Member Author

ahoppen commented May 26, 2021

@swift-ci Please test

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.

Formatting in the test is a bit off (the class init/subscript use 4 space and then the example func 2 space), but LGTM otherwise.

@ahoppen ahoppen force-pushed the pr/dont-crash-call-to-init branch from eca6d93 to 3c1b0d2 Compare May 27, 2021 09:50
@ahoppen
Copy link
Member Author

ahoppen commented May 27, 2021

That’s what you get from copy-pasting code with tabs and setting your tab size to 2. Updated the formatting in the test case.

…ntains a call to init

We were trying to retrieve the name of all function calls in the body using `getBaseIdentifier`. But calls to `init` don’t have a base identifier, just a `DeclBaseName` (which is special). Work with the `DeclBaseName` internally to prevent the crash.

Fixes rdar://78024731 [SR-14637]
@swiftlang swiftlang deleted a comment from swift-ci May 31, 2021
@swiftlang swiftlang deleted a comment from swift-ci May 31, 2021
@swiftlang swiftlang deleted a comment from swift-ci May 31, 2021
@swiftlang swiftlang deleted a comment from swift-ci May 31, 2021
@ahoppen ahoppen force-pushed the pr/dont-crash-call-to-init branch from 3c1b0d2 to 58be2bf Compare May 31, 2021 10:21
@ahoppen
Copy link
Member Author

ahoppen commented May 31, 2021

@swift-ci Please test Linux

@ahoppen
Copy link
Member Author

ahoppen commented May 31, 2021

@swift-ci Please test macOS

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