Skip to content

Address review feedback #956

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
Oct 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions Sources/SwiftParser/Declarations.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1121,11 +1121,7 @@ extension Parser {
}

// Detect an attempt to use a type parameter pack.
var unexpectedAfterName: RawUnexpectedNodesSyntax?
if let ellipsis = tryConsumeEllipsisPrefix() {
unexpectedAfterName = RawUnexpectedNodesSyntax(
elements: [RawSyntax(ellipsis)], arena: self.arena)
}
let ellipsis = tryConsumeEllipsisPrefix()

// Parse optional inheritance clause.
let inheritance: RawTypeInheritanceClauseSyntax?
Expand Down Expand Up @@ -1162,7 +1158,7 @@ extension Parser {
associatedtypeKeyword: assocKeyword,
unexpectedBeforeName,
identifier: name,
unexpectedAfterName,
RawUnexpectedNodesSyntax([ellipsis], arena: self.arena),
inheritanceClause: inheritance,
initializer: defaultType,
genericWhereClause: whereClause,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,8 @@ public class ParseDiagnosticsGenerator: SyntaxAnyVisitor {
addDiagnostic(incorrectContainer, message(misplacedTokens), fixIts: fixIts, handledNodes: [incorrectContainer.id] + correctAndMissingTokens.map(\.id))
}

/// Utility function to remove a misplaced token with a custom error message.
/// If `unexpected` only contains a single token that satisfies `predicate`,
/// emits a diagnostic with `message` that removes this token.
public func removeToken(
_ unexpected: UnexpectedNodesSyntax?,
where predicate: (TokenSyntax) -> Bool,
Expand Down