tree-sitter-c-sharp
tree-sitter-c-sharp copied to clipboard
Incorrect test for conditional access expression with simple member access
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.
See also #131. This comment seems to have a correct test.