Skip to content
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
2 changes: 2 additions & 0 deletions Sources/SwiftParser/Declarations.swift
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ extension TokenConsumer {
// FIXME: C++ parser returns true if this is a top-level non-"script" files.
// But we don't have "is library" flag.
return false
case .rhs(._borrowing), .rhs(._consuming), .rhs(._mutating):
return experimentalFeatures.contains(.referenceBindings)
case .some(_):
// All other decl start keywords unconditionally start a decl.
return true
Expand Down
4 changes: 4 additions & 0 deletions Sources/SwiftParser/TokenConsumer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ protocol TokenConsumer {
associatedtype Token
/// The current token syntax being examined by the consumer
var currentToken: Lexer.Lexeme { get }

/// The experimental features that have been enabled.
var experimentalFeatures: Parser.ExperimentalFeatures { get }

/// Whether the current token matches the given kind.
mutating func consumeAnyToken() -> Token

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,7 @@ final class PatternWithoutVariablesTests: ParserTestCase {
)
}

func testMutatingNotADeclarationStartIfNotEnabled() {
assertParse("_mutating = 2")
}
}