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-14553] Previously unknown syntax is now parsed as AttributedTypeSyntax; not sure if expected #399

Closed
allevato opened this issue Apr 30, 2021 · 6 comments
Labels
bug Something isn't working

Comments

@allevato
Copy link
Collaborator

Previous ID SR-14553
Radar rdar://problem/77378237
Original Reporter @allevato
Type Bug
Status Resolved
Resolution Won't Do

Attachment: Download

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

md5: f6d34be3c638dad74afac4d3f62c9a33

Issue Description:

In swift-format, we were using the following code snippet to test how we handled syntax trees that contained Unknown*Syntax nodes:

{{ @unknown foo class Bar {}}}

At some point fairly recently in main (I'm using the 2021-04-26 development snapshot), the parser behavior changed and it now parses this as valid; the result is two CodeBlockItems:

  1. a TypeExpr containing the AttributedType @unknown foo

  2. the ClassDecl class Bar {}

Something similar happens with a malformed @unknown default:

{{ switch a {}}
{{ case x: break}}
{{ @unknown foo default: break}}
{{ }}}

This body of case x is parsed as two CodeBlockItems (break, then @unknown foo), and then the next SwitchCase starts at the default.

Are these changes expected?

To reproduce:

  1. Download the attached project.

  2. Use a development toolchain that is syntax-compatible with swift-syntax's main branch (at the time I'm writing this, 2021-04-26 worked).

  3. Run swift run UnknownAttr.

  4. Observe the tree output.

@typesanitizer
Copy link

@swift-ci create

@ahoppen
Copy link
Collaborator

ahoppen commented May 4, 2021

@allevato How recently were you seeing the changes? With which toolchain were you still seeing the unknown syntax nodes? If it’s a toolchain from before October last year, this might be due to apple/swift#34257

As far as I’m concerned, I’m also fine with the new parsing behavior and don’t see a reason to revert it.

@ahoppen
Copy link
Collaborator

ahoppen commented May 19, 2021

@allevato Ping

@allevato
Copy link
Collaborator Author

Sigh, I apologize for the late reply. It looks like I'm not getting e-mail updates from Jira even though everything looks like it's configured correctly.

The first time I noticed the change in behavior was in the 2021-04-26 development snapshot. Unfortunately my workstation released its magic smoke a couple weeks ago so I can't check my history, but a colleague says that he has toolchains from 2021-01-17 and 2021-03-25 installed from work on other swift-format PRs, so I think the change affecting this unknown syntax must have occurred at least after 2021-01-17 or else we would have detected it during testing of apple/swift-format#249

My suspicion was that it might have been related to some of the recent work around local property wrappers or property wrappers in function signatures, but I couldn't pinpoint anything specific.

FWIW, I also don't have any issues about the way that it's parsed now—I primarily wanted to make sure that this wasn't an unintended change. Since it sounds like you feel the same way, feel free to resolve this—thanks!

@typesanitizer
Copy link

There was some bug in the JIRA instance for a bit where none of us were receiving emails. It was fixed in the evening on May 19.

@ahoppen
Copy link
Collaborator

ahoppen commented Jun 11, 2021

Thanks for your feedback on this @allevato. I’ve closed this as “Won’t do”.

@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
adevress pushed a commit to adevress/swift-syntax that referenced this issue Jan 14, 2024
Support designated types for operator declarations.
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants