Skip to content

Invalidate default argument exprs if typechecking fails #8059

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
Mar 14, 2017

Conversation

CodaFi
Copy link
Contributor

@CodaFi CodaFi commented Mar 14, 2017

While looking through the crashers, I noticed a large portion of them involved type checking default argument expressions. Round about the time there was an effort to remove the ExprHandle type, these crashes showed up. This little bit of code was attempting to type check default argument initializers, then would ask the expression handle to write the old expression value back into the parameter if it failed - though I'm not sure this was correct either. When this got refactored, the error path got ditched. In any case, the right behavior is not to keep a reference to a tree of dangling type variables. Instead, invalidate the initializer expression in the AST, then continue type checking it to see if we can get some useful diagnostics.

This patch resolves 22 crashers.

Because this touches dangling type variables: @rudkx, what do you think?

@slavapestov
Copy link
Contributor

We have a bunch of disabled crashers with 'REQUIRES: deterministic-behavior' and a few with 'REQUIRES: SR-xyz'. Can you check if those pass now?

@rudkx
Copy link
Contributor

rudkx commented Mar 14, 2017

LGTM, and despite the fact that my (still in-progress changes) would have fixed this I would rather surgically fix it now with your change and make sure it's fixed than wait until those changes are ultimately enabled.

As for the deterministic-behavior crashers - I'd suggest enabling the ones that seem to pass in a completely separate commit so it is easy to revert that commit if anything goes wrong while still keeping the goodness here.

@CodaFi
Copy link
Contributor Author

CodaFi commented Mar 14, 2017

I agree, I'll submit a separate patch that checks to see if the non-deterministic crashers actually got fixed. Now that I actually ran resolve-crashes over them it solves quite a bit more than I'm comfortable committing.

@CodaFi
Copy link
Contributor Author

CodaFi commented Mar 14, 2017

@swift-ci please smoke test

@CodaFi
Copy link
Contributor Author

CodaFi commented Mar 14, 2017

Make that 23.

@CodaFi CodaFi force-pushed the initial-value-problem branch from 4a15237 to 024a072 Compare March 14, 2017 02:46
@CodaFi
Copy link
Contributor Author

CodaFi commented Mar 14, 2017

@swift-ci please smoke test

@slavapestov
Copy link
Contributor

Oops - looks like you made a typo when resolving 28716

@CodaFi
Copy link
Contributor Author

CodaFi commented Mar 14, 2017

Probably for the best, I have to rebase onto @practicalswift's last commit anyway.

@@ -6,5 +6,5 @@
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors

// REQUIRES: OS=linux-gnu
Copy link
Contributor

Choose a reason for hiding this comment

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

Also please remove this REQUIRES line

@CodaFi CodaFi force-pushed the initial-value-problem branch 2 times, most recently from 641d3da to 84be050 Compare March 14, 2017 03:24
@slavapestov
Copy link
Contributor

Oh fixed crashers should not have a REQUIRES: asserts since they're fixed - they won't hit asserts.

I had a look at the disabled crashers, all seem to be default arg related too. Looking forward to those getting resolved in the next PR :-)

If typechecking fails, the expression will have unsolved type variables
written into it.  This Crashes The Compiler.

In that case, there’s no reason to keep a tree of dangling references
around.  Detach the initializer expression from the AST, but continue
to typecheck it to see if we can get some useful diagnostics out of it.
@CodaFi CodaFi force-pushed the initial-value-problem branch from 84be050 to 1367b0c Compare March 14, 2017 03:27
@CodaFi
Copy link
Contributor Author

CodaFi commented Mar 14, 2017

@swift-ci please smoke test and merge

@swift-ci swift-ci merged commit dced34a into swiftlang:master Mar 14, 2017
@CodaFi CodaFi deleted the initial-value-problem branch March 14, 2017 03:59
CodaFi added a commit to CodaFi/swift that referenced this pull request Mar 14, 2017
These were leftover from the swiftlang#8059, which plugged a type variable leak
caused by type checking invalid default argument expressions.
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.

4 participants