Skip to content

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

Closed
swiftlang/swift-syntax
#2825
@tayloraswift

Description

@tayloraswift

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

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