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
Comments
@swift-ci create |
@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. |
@allevato Ping |
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! |
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. |
Thanks for your feedback on this @allevato. I’ve closed this as “Won’t do”. |
Support designated types for operator declarations.
Attachment: Download
Additional Detail from JIRA
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
:a
TypeExpr
containing theAttributedType
@unknown foo
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 twoCodeBlockItems
(break
, then@unknown foo
), and then the nextSwitchCase
starts at thedefault
.Are these changes expected?
To reproduce:
Download the attached project.
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).
Run
swift run UnknownAttr
.Observe the tree output.
The text was updated successfully, but these errors were encountered: