-
Notifications
You must be signed in to change notification settings - Fork 439
Expand trailing comma implementation #2689
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -315,7 +315,7 @@ extension Parser { | |
arena: self.arena | ||
) | ||
) | ||
} while keepGoing != nil && self.hasProgressed(&loopProgress) | ||
} while keepGoing != nil && !self.atInheritanceListTerminator() && self.hasProgressed(&loopProgress) | ||
} | ||
|
||
let unexpectedAfterInheritedTypeCollection: RawUnexpectedNodesSyntax? | ||
|
@@ -339,6 +339,10 @@ extension Parser { | |
) | ||
} | ||
|
||
mutating func atInheritanceListTerminator() -> Bool { | ||
return self.experimentalFeatures.contains(.trailingComma) && (self.at(.leftBrace) || self.at(.keyword(.where))) | ||
} | ||
mateusrodriguesxyz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
Comment on lines
+342
to
+345
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this doesn’t work in general because Eg. associatedtype Iterator: IteratorProtocol, would probably fail to parse wit this change. I think we should limit the trailing comma to the types where it is guaranteed to be followed by There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ahoppen I believe it's just a matter of update the proposal text mentioning that trailing comma won't work for inheritance clause of an associatedtype, right? The same for where clauses for protocol definition. In general, make it clear that trailing comma will only be allowed when there's a clear terminator. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I’m only speaking as a reviewer of this PR here but I think it would make sense to exclude trailing commas for these situations without a clear terminator from the evolution proposal for now. There might be ways of getting them right, but doing so is more complicated than the cases that have a clear terminator. Highlighting these situations in a Future directions section would make sense, I think. That way your proposal can focus on the majority of cases and if we do choose to extend trailing commas eg. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've updated the proposal text highlighting these cases. Thanks for catching them. |
||
mutating func parsePrimaryAssociatedTypes() -> RawPrimaryAssociatedTypeClauseSyntax { | ||
let langle = self.consumePrefix("<", as: .leftAngle) | ||
var associatedTypes = [RawPrimaryAssociatedTypeSyntax]() | ||
|
Uh oh!
There was an error while loading. Please reload this page.