-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Parse] Do not parse generic arguments of a cast destination if the token is more than a <
#60088
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
Closed
Closed
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
6021739
Fix [SR-436] Parse failure that shouldn’t be
simanerush 253ae12
add expected error
simanerush 56681e9
Add FIXME
simanerush 34c53c7
Change comment, add more tests.
simanerush 381f075
Improve readability of expected diagnostics comments
simanerush 288f957
Fix comment formatting & remove unnecessary check
simanerush 6d3503b
Now actually fix comment formatting
simanerush 7274fdc
Update lib/Parse/ParseType.cpp
simanerush 80cd290
Update lib/Parse/ParseType.cpp
simanerush File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't we just use
canParseAsGenericArgumentList()
instead ofstartsWithLess(Tok)
like expression parsing?It only accepts single
<
, but I'm not sure there's a place we need to accept<<
for a generic arguments in the first place. If we cannot usecanParseAsGenericArgumentList()
, could you add some code-comment to explain why not?Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see we don't use
canParseAsGenericArgumentList()
probably because of the SIL type parsing which has generic function types like<T> (T) -> Void
. And for non-expression position, we probably want to diagnose errors inside<...>
as a generic argument error, but not as a bogus random tokens after a type. E.g.The error in
<String: Int>
should be diagnosed as likeexpected ',' instead of ':'
insideparseGenericArguments()
. But if we usedcanParseAsGenericArgumentList()
here, it would be parsed as a random tokens afterlet a: Dictionary
.So I think having
ParseTypeReason::CastDestination
actually makes sense. And we can usecanParseAsGenericArgumentList()
only forCastDestination
case.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the feedback!