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

Precedence incorrect between or and conditional access #233

Open
Sjord opened this issue Sep 14, 2022 · 2 comments
Open

Precedence incorrect between or and conditional access #233

Sjord opened this issue Sep 14, 2022 · 2 comments

Comments

@Sjord
Copy link
Collaborator

Sjord commented Sep 14, 2022

x || x?.C;

Parsed as (x || x)?.C instead of x || (x?.C).

Actual:

(compilation_unit [0, 0] - [1, 0]
  (global_statement [0, 0] - [0, 10]
    (expression_statement [0, 0] - [0, 10]
      (conditional_access_expression [0, 0] - [0, 9]
        condition: (binary_expression [0, 0] - [0, 6]
          left: (identifier [0, 0] - [0, 1])
          right: (identifier [0, 5] - [0, 6]))
        (member_binding_expression [0, 7] - [0, 9]
          name: (identifier [0, 8] - [0, 9]))))))

Expected:

(compilation_unit [0, 0] - [1, 0]
  (global_statement [0, 0] - [0, 11]
    (expression_statement [0, 0] - [0, 11]
      (binary_expression [0, 0] - [0, 10]
        left: (identifier [0, 0] - [0, 1])
        right: (conditional_access_expression [0, 5] - [0, 9]
            condition: (identifier [0, 5] - [0, 6])
            (member_binding_expression [0, 7] - [0, 9]
              name: (identifier [0, 8] - [0, 9])))))))
@damieng
Copy link
Contributor

damieng commented Sep 15, 2022

I think this one is also related to #172

@Sjord
Copy link
Collaborator Author

Sjord commented Jan 15, 2024

Test case:

=====================================
Precedence between or and conditional access
=====================================

var a = x || x?.C;

---

(compilation_unit
  (global_statement
    (local_declaration_statement
      (variable_declaration
        type: (implicit_type)
        (variable_declarator
          name: (identifier)
          (equals_value_clause
             (binary_expression
               left: (identifier)
               right: (conditional_access_expression
                   condition: (identifier)
                   (member_binding_expression
                     name: (identifier))))))))))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants