Skip to content

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

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

Closed
kntkymt opened this issue Apr 19, 2025 · 0 comments · Fixed by #80928
Closed
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. triage needed This issue needs more specific labels

Comments

@kntkymt
Copy link
Contributor

kntkymt commented Apr 19, 2025

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. triage needed This issue needs more specific labels
Projects
None yet
1 participant