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-13541] Incorrect parsing of TernarySyntax #408

Closed
swift-ci opened this issue Sep 11, 2020 · 3 comments
Closed

[SR-13541] Incorrect parsing of TernarySyntax #408

swift-ci opened this issue Sep 11, 2020 · 3 comments
Labels
bug Something isn't working

Comments

@swift-ci
Copy link
Contributor

Previous ID SR-13541
Radar rdar://problem/68728159
Original Reporter mkruber (JIRA User)
Type Bug
Status Resolved
Resolution Invalid
Additional Detail from JIRA
Votes 0
Component/s SwiftSyntax
Labels Bug
Assignee None
Priority Medium

md5: 6f8e53a86a4d051eb4c976739f568e96

Issue Description:

It appears that TernarySyntax is not being parsed correctly. For instance, the following statement is parsed as a SequenceExprSyntax.

helper_func() == p1 ? true : false

However, the following is parsed correctly as a TernarySyntax.

p1 ? true : false

This problem is observed with SwiftSyntax 5.2
@typesanitizer
Copy link

@swift-ci create

@rintaro
Copy link
Mannequin

rintaro mannequin commented Sep 15, 2020

a == b ? c : d is currently parsed like

(sequence_expr
  (identifier_expr "a")
  (binary_operator "==")
  (ternary_operator_expr
    (identifier_expr "b")
    (identifier_expr "c")
    (identifier_expr "d")))

Since Parser doesn't know the precedence of the operators, we can't correctly construct nested binary/ternary operator expressions.

@rintaro
Copy link
Mannequin

rintaro mannequin commented Sep 15, 2020

So it behaves correctly as implemented.

@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
Ensure there is a break between closure attributes and a capture list.
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

2 participants