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

Incorrect test for conditional access expression with simple member access #173

Open
Sjord opened this issue Mar 25, 2021 · 1 comment
Open
Labels

Comments

@Sjord
Copy link
Collaborator

Sjord commented Mar 25, 2021

The test in expressions.txt is incorrect:

=====================================
Conditional access expression with simple member access
=====================================

if ((p as Person[])?[0]._Age != 1) { }

---

(compilation_unit
  (global_statement
    (if_statement
      (binary_expression
          (member_access_expression
            (conditional_access_expression
              (parenthesized_expression
                (as_expression (identifier) (array_type (identifier) (array_rank_specifier))))
              (element_binding_expression
                (bracketed_argument_list (argument (integer_literal)))))
            (identifier))
          (integer_literal))
      (block))))

Actual: The member_access_expression evaluates .Age on a conditional_access_expression, whose value is possibly null.

Expected: The evaluation of .Age is only performed if (p as Person[]) is not null. The member_access_expression should be inside the conditional_access_expression.

@Sjord
Copy link
Collaborator Author

Sjord commented Mar 27, 2021

See also #131. This comment seems to have a correct test.

@damieng damieng added the bug label Apr 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants