Skip to content

[Diag] [Typechecker] Diagnose throw in defer properly #23311

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 4 commits into from
Mar 21, 2019
Merged

[Diag] [Typechecker] Diagnose throw in defer properly #23311

merged 4 commits into from
Mar 21, 2019

Conversation

theblixguy
Copy link
Collaborator

@theblixguy theblixguy commented Mar 14, 2019

The body of a defer statement is an implicit FuncDecl, but that's implementation detail and it shouldn't leak into diagnostics. For example, we end up emitting an incorrect diagnostic when using a throw in a defer:

defer { throw Foo.bar } // error is not handled because the enclosing function is not declared 'throws'

Treat throw the same way we treat other control flow statements, like return, break & yield when used inside a defer.

@theblixguy
Copy link
Collaborator Author

cc @xedin

@xedin xedin self-requested a review March 14, 2019 20:38
Copy link
Contributor

@xedin xedin left a comment

Choose a reason for hiding this comment

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

LGTM!

@xedin
Copy link
Contributor

xedin commented Mar 18, 2019

@swift-ci please smoke test and merge

@xedin
Copy link
Contributor

xedin commented Mar 18, 2019

@theblixguy Looks like there is a problem in verifier.

@theblixguy
Copy link
Collaborator Author

@xedin Hmm this makes sense since we're backing out of error type checking if we're in a defer body. I have fixed it now. Could you trigger the test again? Should be all good!

@xedin
Copy link
Contributor

xedin commented Mar 18, 2019

@swift-ci please smoke test and merge

1 similar comment
@xedin
Copy link
Contributor

xedin commented Mar 19, 2019

@swift-ci please smoke test and merge

@xedin
Copy link
Contributor

xedin commented Mar 19, 2019

@swift-ci please smoke test

@theblixguy
Copy link
Collaborator Author

@xedin Could you trigger the CI again? Had to make a small change! Thank you!

@xedin
Copy link
Contributor

xedin commented Mar 19, 2019

@swift-ci please smoke test

@theblixguy
Copy link
Collaborator Author

Unrelated build failure:

15:10:35 The following build commands failed:
15:10:35 PhaseScriptExecution Install\ Swift\ compiler\ resources /Users/buildnode/jenkins/workspace/swift-PR-osx-smoke-test/branch-master/buildbot_incremental/lldb-macosx-x86_64/lldb.build/CustomSwift-Release/LLDB.build/Script-49DD45051B4EDB4A00DB3579.sh

@xedin
Copy link
Contributor

xedin commented Mar 19, 2019

@swift-ci please smoke test macOS platform

@theblixguy
Copy link
Collaborator Author

theblixguy commented Mar 19, 2019

Seems like the bots are not working correctly today 😅 Something's wrong with LLDB

@xedin
Copy link
Contributor

xedin commented Mar 19, 2019

We'll just have to wait until that's cleared, unfortunately...

@theblixguy
Copy link
Collaborator Author

No problem!

@theblixguy
Copy link
Collaborator Author

Okay, let's give the tests one more try. @xedin can you invoke the CI?

@xedin
Copy link
Contributor

xedin commented Mar 20, 2019

@swift-ci please smoke test

@theblixguy
Copy link
Collaborator Author

All tests have passed 🙏 🎉

@xedin
Copy link
Contributor

xedin commented Mar 20, 2019

Ok, great! Let's run source compatibility just in case...

@xedin
Copy link
Contributor

xedin commented Mar 20, 2019

@swift-ci please test source compatibility

@theblixguy
Copy link
Collaborator Author

Hmm I don't think the source compat test ran (or maybe the CI screwed up) 🤔

Problem accessing /job/swift-PR-source-compat-suite/2695/. Reason:
Not Found

@xedin
Copy link
Contributor

xedin commented Mar 20, 2019

@swift-ci please test source compatibility

@xedin xedin merged commit 8fcd4e6 into swiftlang:master Mar 21, 2019
@theblixguy theblixguy deleted the fix/throw-in-defer branch March 21, 2019 07:08
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