Skip to content

error: new Swift parser generated errors for code that C++ parser accepted #76089

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
tayloraswift opened this issue Aug 26, 2024 · 1 comment · Fixed by swiftlang/swift-syntax#2825
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. triage needed This issue needs more specific labels

Comments

@tayloraswift
Copy link
Member

tayloraswift commented Aug 26, 2024

Description

the code in the snippet raises error: new Swift parser generated errors for code that C++ parser accepted, but only on toolchains with assertions enabled (swift-5.10.1-RELEASE-ubuntu24.04).

for some reason, i could not locate a 6.0 or main branch toolchain for Ubuntu 24.04 on https://www.swift.org/download/ so i was not able to test those versions.

crash2.swift:6:6: error: consecutive statements on a line must be separated by newline or ';'
    } (&y[0])
     ^
crash2.swift:6:6: note: insert newline
    } (&y[0])
     ^
crash2.swift:6:6: note: insert ';'
    } (&y[0])
     ^
      ; 
crash2.swift:1:1: error: new Swift parser generated errors for code that C++ parser accepted
func f(x:[Void])
^
error: fatalError

Reproduction

func f(x:[Void])
{
    var y:[[Void]] = x.map { [$0] }
    {
        $0.reserveCapacity(1)
    } (&y[0])
}

Expected behavior

?

Environment

Swift version 5.10.1 (swift-5.10.1-RELEASE)
Target: x86_64-unknown-linux-gnu

Additional information

No response

@DougGregor
Copy link
Member

The actual bug here is in the swift-syntax parser, fix is at swiftlang/swift-syntax#2825

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
3 participants
@DougGregor @tayloraswift and others