Skip to content

[Parse] Skip attributes in isStartOfDecl(). #5789

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
Nov 18, 2016

Conversation

rintaro
Copy link
Member

@rintaro rintaro commented Nov 15, 2016

Previously, @ token was unconditionally considered as isStartOfDecl()

Since canParseTypeTupleBody() fails at isStartOfDecl(),
generic argument containing type attributes, e.g.
Array<(@convention(block) () -> Int) -> Void>
failed to be parsed.

@rintaro
Copy link
Member Author

rintaro commented Nov 15, 2016

Alternatively, can we simply drop isStartOfDecl() check in canParseTypeTupleBody()?
That passes all test cases we currently have.

@DougGregor
Copy link
Member

This change looks great.

I think the Parser::canParseTypeTupleBody code you referenced is trying to prevent tentative parsing from going off the rails in ill-formed code. It's probably better to leave it.

@rintaro
Copy link
Member Author

rintaro commented Nov 16, 2016

@swift-ci Please smoke test and merge

@rintaro
Copy link
Member Author

rintaro commented Nov 16, 2016

Sorry, I should have throughly tested locally 😓
The failures are because this change can't handle these cases.

@ [code_complete]
func foo() {}
  @something(incomplete
  func foo() { }
}

@rintaro rintaro force-pushed the parse-isstartofdecl-skipattrs branch from ded0407 to 32faeb1 Compare November 16, 2016 08:41
Previously, '@' token was unconditionally considered as isStartOfDecl()

Since canParseTypeTupleBody() fails at isStartOfDecl(),
generics arguments containing attributes, e.g.
Array<(@convention(block) () -> Int) -> Void>
failed to be parsed.
@rintaro rintaro force-pushed the parse-isstartofdecl-skipattrs branch from 32faeb1 to 89d7969 Compare November 16, 2016 09:25
@rintaro
Copy link
Member Author

rintaro commented Nov 16, 2016

@swift-ci Please smoke test

@rintaro
Copy link
Member Author

rintaro commented Nov 16, 2016

@DougGregor Sorry to bother you. Could you take a look again?
Updated the skipping logic.

@DougGregor
Copy link
Member

This revision LGTM, thanks!

@rintaro
Copy link
Member Author

rintaro commented Nov 18, 2016

@swift-ci Please smoke test and merge

@swift-ci swift-ci merged commit 81f9fa2 into swiftlang:master Nov 18, 2016
@rintaro rintaro deleted the parse-isstartofdecl-skipattrs branch November 24, 2016 06:40
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