Skip to content

[code-completion] Fix crash in printParameterList when paramListTy is… #6085

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 2 commits into from
Dec 6, 2016

Conversation

nathawes
Copy link
Contributor

@nathawes nathawes commented Dec 5, 2016

This fixes a crash exposed by validation-test/IDE/crashers/101-swift-decl-print.swift. When paramListTy was Error type, it was still treated as a valid parameter list type. This resulted in a path through the method where the paramFlags vector had fewer elements than the parameter list, PL, so paramFlags[i], where i is an index into PL, triggered an assert.

Resolves rdar://problem/28867801.

… Error type rdar://problem/28867801

@nathawes
Copy link
Contributor Author

nathawes commented Dec 5, 2016

@swift-ci please smoke test

@@ -2461,7 +2461,7 @@ void PrintAST::printParameterList(ParameterList *PL, Type paramListTy,
bool isCurried,
std::function<bool()> isAPINameByDefault) {
SmallVector<ParameterTypeFlags, 4> paramFlags;
if (paramListTy) {
if (paramListTy && !paramListTy.getPointer()->hasError()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Type has an overloaded operator->, so you can just use paramListTy->hasError().

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, I'll fix it up!

@nathawes
Copy link
Contributor Author

nathawes commented Dec 6, 2016

@swift-ci please smoke test

@benlangmuir benlangmuir merged commit 49f1442 into swiftlang:master Dec 6, 2016
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.

3 participants