Skip to content

[Parser] String interpolation accepts invalid argument label syntax without expression #80927

Closed
@kntkymt

Description

@kntkymt

Description

The interpolated string "(1, f:)" compiles without error, despite f: being an argument label with no following expression.

Reproduction

compile the following code.

print("\(10,f:)") // 10

Expected behavior

Should be compile error. Diagnosis should output expected expression in list of expressions.

Environment

swift-driver version: 1.120.5 Apple Swift version 6.1 (swiftlang-6.1.0.110.21 clang-1700.0.13.3)
Target: arm64-apple-macosx15.0

Additional information

Regression of trailing comma

It seems to be regression of SE-0439 Allow trailing comma in comma-separated lists. PR.

When we compile the code in Swift 6.0.3, correctly output the error expected expression in list of expressions

<stdin>:1:16: error: expected expression in list of expressions
1 | print("\(10, f:)")
  |                `- error: expected expression in list of expressions
2 | 
Swift version 6.0.3 (swift-6.0.3-RELEASE)
Target: aarch64-unknown-linux-gnu

ASTGen assertion

Plus I got assertion error between ASTGen parser and c++ parser

<stdin>:1:16: error: expected value in string literal
1 | print("\(10, f:)")
  |                |- error: expected value in string literal
  |                `- note: insert value
2 | 

<stdin>:1:1: error: new Swift parser generated errors for code that C++ parser accepted
1 | print("\(10, f:)")
  | `- error: new Swift parser generated errors for code that C++ parser accepted
2 | 
Swift version 6.2-dev (LLVM 81ab6d9f7e4810f, Swift 9cc1947527bacea)
Target: aarch64-unknown-linux-gnu
Build config: +assertions

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.triage neededThis issue needs more specific labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions