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
[SR-13126] deinit
without braces results in 'unknown' node (shows up when parsing .swiftinterface files)
#409
Comments
Could you provide some more details to help isolate the issue, perhaps an example of a minimal swiftinterface file that demonstrates the problem? What error are you seeing? In principle, swiftinterface files are also using Swift syntax, so swift-syntax should be able to parse them. |
Comment by Jonathan Wight (JIRA) Yeah that's what I'd expect too. In practice I can never get them to load without a SIGILL. For example: ``` import Foundation import SwiftSyntax let url = URL(fileURLWithPath: "/Library/Developer/CommandLineTools/SDKs/MacOSX10.16.sdk/System/Library/Frameworks/RealityKit.framework/Versions/A/Modules/RealityKit.swiftmodule/x86_64.swiftinterface") let parsed = try SyntaxParser.parse(url) try SyntaxVerifier.verify(Syntax(parsed))``` Fatal error: Error raised at top level: unknown syntax node for " |
Comment by Jonathan Wight (JIRA) Attachment added with sample project. |
@swift-ci create |
> Same project cannot parse and dump a .swiftinterface file. Just to make sure it is clear, "try SyntaxVerifier.verify(Syntax(parsed))" is intended to throw an error if "unknown syntax node" is present (it's a verification mechanism as the name implies), this doesn't mean that "parsing and dumping results in SIGILL". In fact, you will find that you can dump a parsed tree fine even with 'unknown' nodes present. It is useful to investigate why the 'unknown' syntax node shows up, and thanks for reporting this, but I want to make sure we are precise in what the exact issue is here. |
Reduced test case: class Cls { deinit } The missing braces for `deinit` cause the 'unknown' node. |
Some general advice, `.swiftinterface` files are intended to be an implementation detail of the compiler, the fact that they are textual and contain swift source code is an implementation detail, they are not intended to be readable by users or external tools outside the compiler. Please keep this in mind and reach out for the use cases that you have in mind to so we could provide advice. |
In this particular case it would be useful to still produce a `DeinitializerDecl` even if braces are missing, as part of parser recovery, independent of .swiftinterface files. |
Resolved in the new parser by #716 |
Attachment: Download
Environment
Tested against release/5.3 of swift-syntax
Additional Detail from JIRA
md5: af87e62f21e27dd8333ceb97a0b8d3a2
Issue Description:
I have a test project using swift-syntax. Project can parse and dump a .swift file successfully. Same project cannot parse and dump a .swiftinterface file.
It would be super-useful to be able to parse .swiftinterface files too.
The text was updated successfully, but these errors were encountered: