Skip to content

[6.0] SILGen: Skip function bodies with errors in lazy typechecking mode #75102

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

Conversation

tshortli
Copy link
Contributor

@tshortli tshortli commented Jul 9, 2024

  • Explanation: The SILGen pipeline expects function bodies to have been successfully type checked and will usually crash if it attempts to emit SIL for a function that has errors. In lazy typechecking mode, function bodies are type checked on-demand and therefore bodies containing errors can make it to SILGen. To avoid crashing in this scenario, move function body typechecking earlier in lazy typechecking mode and then skip SIL generation whenever any errors have been recorded in the ASTContext.
  • Scope: Affects module emission in builds with lazy typechecking enabled. Fixing this for 6.0 is important because the crashes that occur otherwise make qualification difficult because they obscure project issues.
  • Issue/Radar: rdar://130777647
  • Original PR: SILGen: Skip function bodies with errors in lazy typechecking mode #74837
  • Risk: Low. The new logic only has an effect when lazy typechecking is enabled, reducing its scope.
  • Testing: New test case added.
  • Reviewer: @jckarter

The SILGen pipeline expects function bodies to have been succesfully type
checked and will usually crash if it attempts to emit SIL for a function that
has errors. To avoid crashing, cause function body typechecking to happen
earlier in lazy typechecking mode and then skip functions whenever any errors
have been encountered.

Resolves rdar://130777647.
@tshortli
Copy link
Contributor Author

tshortli commented Jul 9, 2024

@swift-ci please test

@tshortli tshortli changed the title SILGen: Skip function bodies with errors in lazy typechecking mode. [6.0] SILGen: Skip function bodies with errors in lazy typechecking mode Jul 9, 2024
@tshortli tshortli marked this pull request as ready for review July 9, 2024 15:34
@tshortli tshortli requested a review from a team as a code owner July 9, 2024 15:34
@tshortli tshortli added 🍒 release cherry pick Flag: Release branch cherry picks swift 6.0 labels Jul 9, 2024
Copy link
Member

@DougGregor DougGregor left a comment

Choose a reason for hiding this comment

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

This looks safe to take.

@tshortli
Copy link
Contributor Author

tshortli commented Jul 9, 2024

@swift-ci please test macOS

@tshortli tshortli enabled auto-merge July 9, 2024 15:50
@tshortli tshortli merged commit 88623a4 into swiftlang:release/6.0 Jul 9, 2024
5 checks passed
@tshortli tshortli deleted the silgen-function-body-error-6.0 branch July 9, 2024 22:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🍒 release cherry pick Flag: Release branch cherry picks swift 6.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants