Skip to content

fix: handle TemplateLiteral in convert_ast_to_ir to register pipes and resolve @let variables#259

Merged
Brooooooklyn merged 2 commits intovoidzero-dev:mainfrom
ashley-hunter:template-literal-pipe
May 5, 2026
Merged

fix: handle TemplateLiteral in convert_ast_to_ir to register pipes and resolve @let variables#259
Brooooooklyn merged 2 commits intovoidzero-dev:mainfrom
ashley-hunter:template-literal-pipe

Conversation

@ashley-hunter
Copy link
Copy Markdown
Contributor

@ashley-hunter ashley-hunter commented May 5, 2026

Summary

  • Root cause: AngularExpression::TemplateLiteral had no explicit arm in convert_ast_to_ir() (ingest.rs) and fell through to store_and_ref_expr, which stores the entire node as a raw AST blob. This made the inner BindingPipe invisible to pipe_creation (no pipe slot allocated) and prevented resolve_names from resolving @let variable reads inside the literal.
  • Fix: Added TemplateLiteral arms in three phases — ingest.rs (create IrExpression::ResolvedTemplateLiteral by recursively converting inner expressions), pipe_creation.rs (traverse inner expressions to register pipes), and resolve_names.rs (traverse inner expressions to resolve lexical reads).
  • Affected template pattern: {{ `${num | percent}` }} with an @let variable and pipe inside a template literal — previously produced incorrect output where the pipe was never registered and the variable was resolved against ctx instead of the local scope.

Test plan

  • New Rust integration tests in tests/integration_test.rs (7 tests): pipe inside template literal, pipe + surrounding text, no-pipe regression, attribute binding, multiple pipes, pipe in child view
  • Conformance verified against @angular/compiler 21.2.4 — identical runtime call sequence
  • TypeScript NAPI tests added in napi/angular-compiler/test/transform.test.ts

…d resolve @let variables

TemplateLiteral was not handled in convert_ast_to_ir and fell through to
store_and_ref_expr, so any BindingPipe inside was never registered with
pipe_creation and @let variable reads were resolved against ctx instead
of the local scope.

Fix adds an explicit arm for AngularExpression::TemplateLiteral that
recursively converts inner expressions via convert_ast_to_ir, producing
IrExpression::ResolvedTemplateLiteral with properly converted children.
Also adds ResolvedTemplateLiteral traversal to pipe_creation and
resolve_names so pipes are discovered and names are resolved correctly.

Confirmed output matches Angular 21.2.4 ngtsc for the same templates.
@Brooooooklyn Brooooooklyn merged commit 48f9fe7 into voidzero-dev:main May 5, 2026
9 checks passed
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

Successfully merging this pull request may close these issues.

2 participants