Skip to content

[Parse] Fix parsing "protocol<Any>" #5251

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
Oct 12, 2016

Conversation

rintaro
Copy link
Member

@rintaro rintaro commented Oct 12, 2016

Fix crash while constructing diagnostic fix-it for deprecated syntax.

Also, protocol<>? used to be fixed as just Any. It should be Any? instead.

Fix crash while constructing diagnostic fix-it for deprecated syntax.
(because of accessing elements in empty SmallVector)

```
0  swift                    0x000000010a1682ed PrintStackTraceSignalHandler(void*) + 45
1  swift                    0x000000010a167d36 SignalHandler(int) + 470
2  libsystem_platform.dylib 0x00007fff9452852a _sigtramp + 26
3  libsystem_platform.dylib 000000000000000000 _sigtramp + 1806531312
4  swift                    0x0000000107c6904a swift::Lexer::getTokenAtLocation(swift::SourceManager const&, swift::SourceLoc) + 490
5  swift                    0x0000000107cde0f2 swift::Parser::parseTypeIdentifierOrTypeComposition() + 1698
6  swift                    0x0000000107cdf2ec swift::Parser::parseType(swift::Diag<>, bool) + 380
7  swift                    0x0000000107c8d9e0 swift::Parser::parseExprSequence(swift::Diag<>, bool, bool) + 1456
8  swift                    0x0000000107c8d3c4 swift::Parser::parseExprImpl(swift::Diag<>, bool) + 148
9  swift                    0x0000000107ccdfed swift::Parser::parseExprOrStmt(swift::ASTNode&) + 429
10 swift                    0x0000000107cd5212 swift::Parser::parseBraceItems(llvm::SmallVectorImpl<swift::ASTNode>&, swift::BraceItemListKind, swift::BraceItemListKind) + 2994
11 swift                    0x0000000107c69598 swift::Parser::parseTopLevel() + 184
12 swift                    0x0000000107ca3a4f swift::parseIntoSourceFile(swift::SourceFile&, unsigned int, bool*, swift::SILParserState*, swift::PersistentParserState*, swift::DelayedParsingCallbacks*) + 239
13 swift                    0x0000000107ac77a4 swift::CompilerInstance::performSema() + 5156
14 swift                    0x000000010756ef1d performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*) + 2765
15 swift                    0x000000010756c175 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 17029
16 swift                    0x00000001075293bd main + 8685
17 libdyld.dylib            0x00007fff998ea5ad start + 1
Stack dump:
0.      Program arguments: /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -interpret test.swift -target x86_64-apple-macosx10.9 -enable-objc-interop -sdk /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -color-diagnostics -module-name test
1.      With parser at source location: test.swift:2:1
Segmentation fault: 11
```
in fixit for deprecated protocol composition with trailing characters.

protocol<>?       => Any?
protocol<P1>?     => P1?
protocol<P1, P2>? => (P1 & P2)?
@rintaro
Copy link
Member Author

rintaro commented Oct 12, 2016

@swift-ci Please smoke test

Copy link
Contributor

@jrose-apple jrose-apple left a comment

Choose a reason for hiding this comment

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

Thanks, Rintaro!

@rintaro rintaro merged commit 4e83034 into swiftlang:master Oct 12, 2016
@rintaro rintaro deleted the parse-protocol-any branch October 12, 2016 17:05
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