@@ -286,7 +286,11 @@ final class DeclarationTests: XCTestCase {
286286 fileprivate fileprivate(set) var fileprivateProp = 0
287287 private private(set) var privateProp = 0
288288 internal(set) var defaultProp = 0
289- """
289+ """ ,
290+ diagnostics: [
291+ DiagnosticSpec ( locationMarker: " 1️⃣ " , message: " consecutive statements on a line must be separated by ';' " ) ,
292+ DiagnosticSpec ( locationMarker: " 2️⃣ " , message: " consecutive statements on a line must be separated by ';' " ) ,
293+ ]
290294 )
291295
292296 AssertParse (
@@ -1408,6 +1412,79 @@ final class DeclarationTests: XCTestCase {
14081412 """
14091413 )
14101414 }
1415+
1416+ func testCallToOpenThatLooksLikeDeclarationModifier( ) {
1417+ AssertParse (
1418+ """
1419+ func test() {
1420+ open(set)
1421+ var foo = 2
1422+ }
1423+ """ ,
1424+ substructure: Syntax (
1425+ FunctionCallExprSyntax (
1426+ calledExpression: IdentifierExprSyntax ( identifier: . identifier( " open " ) ) ,
1427+ leftParen: . leftParenToken( ) ,
1428+ argumentList: TupleExprElementListSyntax ( [
1429+ TupleExprElementSyntax (
1430+ expression: IdentifierExprSyntax ( identifier: . identifier( " set " ) )
1431+ )
1432+ ] ) ,
1433+ rightParen: . rightParenToken( )
1434+ )
1435+ )
1436+ )
1437+ }
1438+
1439+ func testReferenceToOpenThatLooksLikeDeclarationModifier( ) {
1440+ // Ideally, this should be parsed as an identifier expression to 'open',
1441+ // followed by a variable declaration but the current behavior matches the C++ parser.
1442+ AssertParse (
1443+ """
1444+ func test() {
1445+ open
1446+ var foo = 2
1447+ }
1448+ """ ,
1449+ substructure: Syntax (
1450+ VariableDeclSyntax (
1451+ modifiers: ModifierListSyntax ( [
1452+ DeclModifierSyntax ( name: . keyword( . open) )
1453+ ] ) ,
1454+ bindingKeyword: . keyword( . var) ,
1455+ bindings: PatternBindingListSyntax ( [
1456+ PatternBindingSyntax (
1457+ pattern: IdentifierPatternSyntax ( identifier: . identifier( " foo " ) ) ,
1458+ initializer: InitializerClauseSyntax (
1459+ value: IntegerLiteralExprSyntax ( digits: . integerLiteral( " 2 " ) )
1460+ )
1461+ )
1462+ ] )
1463+ )
1464+ )
1465+ )
1466+ }
1467+
1468+ func testOpenVarInCodeBlockItemList( ) {
1469+ AssertParse (
1470+ """
1471+ func test() {
1472+ open var foo = 2
1473+ }
1474+ """ ,
1475+ substructure: Syntax ( DeclModifierSyntax ( name: . keyword( . open) ) )
1476+ )
1477+ }
1478+
1479+ func testAsyncLetInLocalContext( ) {
1480+ AssertParse (
1481+ """
1482+ func foo() async {
1483+ async let x: String = " x "
1484+ }
1485+ """
1486+ )
1487+ }
14111488}
14121489
14131490extension Parser . DeclAttributes {
0 commit comments