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

[SR-13126] deinit without braces results in 'unknown' node (shows up when parsing .swiftinterface files) #409

Open
swift-ci opened this issue Jul 1, 2020 · 8 comments
Labels
bug

Comments

@swift-ci
Copy link
Contributor

@swift-ci swift-ci commented Jul 1, 2020

Previous ID SR-13126
Radar rdar://problem/65192354
Original Reporter schwa (JIRA User)
Type Bug

Attachment: Download

Environment

Tested against release/5.3 of swift-syntax

Additional Detail from JIRA
Votes 0
Component/s SwiftSyntax
Labels Bug
Assignee None
Priority Medium

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.

@typesanitizer
Copy link

@typesanitizer typesanitizer commented Jul 4, 2020

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.

@swift-ci
Copy link
Contributor Author

@swift-ci swift-ci commented Jul 7, 2020

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 "
@objc deinit": file /XXXXX/swiftlang/swiftlang-1200.2.10.322/swift/stdlib/public/core/ErrorType.swift, line 200

@swift-ci
Copy link
Contributor Author

@swift-ci swift-ci commented Jul 7, 2020

Comment by Jonathan Wight (JIRA)

Attachment added with sample project.

@typesanitizer
Copy link

@typesanitizer typesanitizer commented Jul 7, 2020

@swift-ci create

@akyrtzi
Copy link
Member

@akyrtzi akyrtzi commented Jul 15, 2020

> 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.

@akyrtzi
Copy link
Member

@akyrtzi akyrtzi commented Jul 15, 2020

Reduced test case:

class Cls { deinit } 

The missing braces for `deinit` cause the 'unknown' node.

@akyrtzi
Copy link
Member

@akyrtzi akyrtzi commented Jul 15, 2020

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.

@akyrtzi
Copy link
Member

@akyrtzi akyrtzi commented Jul 15, 2020

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.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug
Projects
None yet
Development

No branches or pull requests

4 participants