718d7fe5fe
Previously, ternary expressions were emitted as: condExpr ? trueCase : falseCase However, this causes problems when ternary operations are nested. In particular, a template expression of the form: a?.b ? c : d would have compiled to: a == null ? null : a.b ? c : d The ternary operator is right-associative, so that expression is interpreted as: a == null ? null : (a.b ? c : d) when in reality left-associativity is desired in this particular instance: (a == null ? null : a.b) ? c : d This commit adds a check in the expression translator to detect such left-associative usages of ternaries and to enforce such associativity with parentheses when necessary. A test is also added for the template type-checking expression translator, to ensure it correctly produces right-associative expressions for ternaries in the user's template. Fixes #34087 PR Close #34221 |
||
---|---|---|
.. | ||
BUILD.bazel | ||
README.md | ||
mock_compile.ts | ||
mock_compiler_spec.ts | ||
r3_compiler_compliance_spec.ts | ||
r3_view_compiler_binding_spec.ts | ||
r3_view_compiler_di_spec.ts | ||
r3_view_compiler_directives_spec.ts | ||
r3_view_compiler_i18n_spec.ts | ||
r3_view_compiler_input_outputs_spec.ts | ||
r3_view_compiler_listener_spec.ts | ||
r3_view_compiler_providers_spec.ts | ||
r3_view_compiler_spec.ts | ||
r3_view_compiler_styling_spec.ts | ||
r3_view_compiler_template_spec.ts |
README.md
Tests in this directory should be run with:
yarn bazel test --config=ivy packages/compiler-cli/test/compliance:compliance