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-14929] Nested postfix #if expressions are parsed as UnknownExprSyntax #57272

Open
allevato opened this issue Jul 15, 2021 · 1 comment
Open
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself

Comments

@allevato
Copy link
Collaborator

Previous ID SR-14929
Radar rdar://80688328
Original Reporter @allevato
Type Bug
Environment

Swift 5.5 (Xcode 13b2), or parser library built from main on 7/14

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

md5: 26a3a45b0f82837a01776b29f02785f7

Issue Description:

When implementing PostfixIfConfigExprSyntax support for swift-format, I found that nested #if expressions are being returned as UnknownExprSyntax nodes rather than PostfixIfConfigExprSyntax. For example, in this snippet:

receiver
{{ #if ONE}}
{{ #if TWO}}
{{ .call()}}

The outer postfix expression (#if ONE) is PostfixIfConfigExprSyntax, but the inner one (#if TWO) is an UnknownExprSyntax. The inner node's children still appear to be correctly parsed as IfConfigDeclSyntax, however, at least in this simple case; only the expression's node itself was incorrect.

The above code snippet repro's with the syntax parser library built from main (as of 7/14) and also with the Xcode 13b2 compiler using -Xfrontend -emit-syntax:

parse.swift:3:9: error: unknown expression syntax exists in the source
{{ #if TWO}}
{{ ^}}

@rintaro
Copy link
Mannequin

rintaro mannequin commented Jul 15, 2021

@swift-ci create

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
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
Projects
None yet
Development

No branches or pull requests

1 participant