Skip to content
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

Unknown statement syntax when running swiftc with new 5.7 syntax source file #61880

Closed
liuyang1520 opened this issue Nov 2, 2022 · 4 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself † libswiftSyntax † Area → compiler: the once-integrated C++ Syntax library succeeded by SwiftSyntax stale Resolution: No longer relevant, stale unexpected error Bug: Unexpected error

Comments

@liuyang1520
Copy link

Describe the bug
Got unknown statement syntax when running swiftc with new 5.7 syntax source file, for parsing the syntax tree into JSON.

Steps To Reproduce
Steps to reproduce the behavior:

  1. Create a new Swift app in the Xcode
  2. Write a simple function with the new 5.7 if let syntax
    func testExample() throws {
        let app = XCUIApplication()
        app.launch()
        
        var name: String? = "Linda"
        
        if let name {
            print("Hello, \(name)!")
        }
    }
  1. Run swiftc -frontend -emit-syntax test-swift-appUITests/test_swift_appUITests.swift
  2. See the error:
test-swift-appUITests/test_swift_appUITests.swift:32:9: error: unknown statement syntax exists in the source
        if let name {
        ^

Expected behavior
Should get the correct JSON output without error.

Screenshots
image

Environment (please fill out the following information)

  • OS: macOS 12.5.1
  • Xcode Version/Tag/Branch: Version 14.1 (14B47b)
  • Swiftc
swift-driver version: 1.62.15 Apple Swift version 5.7.1 (swiftlang-5.7.1.135.3 clang-1400.0.29.51)
Target: arm64-apple-macosx12.0

Additional context
Add any other context about the problem here.

@liuyang1520 liuyang1520 added the bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. label Nov 2, 2022
@AnthonyLatsis AnthonyLatsis added the compiler The Swift compiler in itself label Nov 10, 2022
@shreyanshp
Copy link

@AnthonyLatsis just a query, should this be raised on https://github.com/apple/swift-driver instead?

@AnthonyLatsis AnthonyLatsis added the † libswiftSyntax † Area → compiler: the once-integrated C++ Syntax library succeeded by SwiftSyntax label Nov 14, 2022
@AnthonyLatsis
Copy link
Collaborator

Nah, this looks like a SE-0345 plumbing oversight in libSwiftSyntax.

cc @calda

@shreyanshp
Copy link

Thank you so much for your response @AnthonyLatsis

Yeah we moved to latest syntax and now emit-syntax is breaking for us

@calda , @AnthonyLatsis let me know if you need any help or any more information to get this fixed please 🙇

@AnthonyLatsis
Copy link
Collaborator

@shreyanshp I am going to close this as not planned because it turns out the -emit-syntax flag is being removed (see #62145 (comment)). swift-syntax is validated against the legacy parser, so it won’t have this issue.

@AnthonyLatsis AnthonyLatsis closed this as not planned Won't fix, can't repro, duplicate, stale Nov 17, 2022
@AnthonyLatsis AnthonyLatsis added the will not do Resolution: Will not be worked on label Nov 17, 2022
@AnthonyLatsis AnthonyLatsis added stale Resolution: No longer relevant, stale and removed will not do Resolution: Will not be worked on labels Feb 2, 2023
@AnthonyLatsis AnthonyLatsis added the unexpected error Bug: Unexpected error label Apr 2, 2023
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. compiler The Swift compiler in itself † libswiftSyntax † Area → compiler: the once-integrated C++ Syntax library succeeded by SwiftSyntax stale Resolution: No longer relevant, stale unexpected error Bug: Unexpected error
Projects
None yet
Development

No branches or pull requests

3 participants