Skip to content

Unexpected macro parsing #1409

Closed
Closed
@TiagoMaiaL

Description

@TiagoMaiaL

Issue Kind

Parse of Valid Source Produced Invalid Syntax Tree

Source Code

struct S {
#if swift(>=2.2)
  let x: Int
#else
  // There should be no error here.
  let x: @#$()%&*)@#$(%&*
#endif
}

Description

The above code is from the swift project, and can be found here.

Instead of parsing x as a constant declaration, with @#$()%&*)@#$(%&* as its type, the above code only parses let x: @ as a variableDecl. The rest of the type is parsed in a wrong way, and the following #$() sequence is parsed as a macroExpansionDecl.

The following test fails:

  func testIfConfigExpr36() {
    AssertParse(
      """
      struct S {
      #if swift(>=2.2)
        let x: Int
      #else
        // There should be no error here.
        let x: @#$()%&*)@#$(%&*
      #endif
      }
      """
    )
  }

Metadata

Metadata

Assignees

No one assigned

    Labels

    SwiftParserBugs in the (new) Parser written in SwiftbugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions