Skip to content

[Sema] Improve handling of invalid protocols during conformance checking #910

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
Jan 10, 2016

Conversation

jtbandes
Copy link
Contributor

@jtbandes jtbandes commented Jan 8, 2016

Fixes 4 compiler_crashers.

@@ -241,7 +241,7 @@ void NormalProtocolConformance::setTypeWitness(
assert(getProtocol() == cast<ProtocolDecl>(assocType->getDeclContext()) &&
"associated type in wrong protocol");
assert(TypeWitnesses.count(assocType) == 0 && "Type witness already known");
assert(!isComplete() && "Conformance already complete?");
assert((!isComplete() || isInvalid()) && "Conformance already complete?");
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note: there is precedent for this; a similar change was made in c52f920

Copy link
Contributor

Choose a reason for hiding this comment

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

This assertion message could be a little bit more precise now, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What would you suggest?

Copy link
Contributor

Choose a reason for hiding this comment

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

You could say "Conformance already complete or invalid" but then one wouldn't know which condition actually failed, so maybe separating into 2 assertions would be better?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

"Well actually" (sorry 😬), it would have to be "Conformance already complete and not invalid". Which to me seems implied by the fact that the assertion is being hit. If it's invalid we don't care whether it's complete.

@practicalswift
Copy link
Contributor

@jtbandes Nice stuff! 👍

Very happy to see these fuzzing cases getting fixed :-)

@jtbandes
Copy link
Contributor Author

jtbandes commented Jan 8, 2016

@practicalswift I'm afraid I'll never catch up with your fuzzer 😄

@practicalswift
Copy link
Contributor

@jtbandes No worries - the number of possible crash locations is finite, so given enough time you'll catch up eventually :-)

@jtbandes
Copy link
Contributor Author

jtbandes commented Jan 9, 2016

But also — thanks for doing the fuzzing! It provides a great source of "intro" bugs for gaining some familiarity with the codebase :)

slavapestov added a commit that referenced this pull request Jan 10, 2016
[Sema] Improve handling of invalid protocols during conformance checking
@slavapestov slavapestov merged commit 8b57337 into swiftlang:master Jan 10, 2016
@jtbandes jtbandes deleted the invalid-proto branch January 10, 2016 07:33
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