Skip to content

fix(compiler): handle tracking expressions requiring temporary variables#58520

Closed
crisbeto wants to merge 1 commit intoangular:mainfrom
crisbeto:56256/nullish-track-pipeline
Closed

fix(compiler): handle tracking expressions requiring temporary variables#58520
crisbeto wants to merge 1 commit intoangular:mainfrom
crisbeto:56256/nullish-track-pipeline

Conversation

@crisbeto
Copy link
Copy Markdown
Member

@crisbeto crisbeto commented Nov 6, 2024

Currently when we generate the tracking expression for a @for block, we process its expression in the context of the creation block. This is incorrect, because the expression may require ops of its own for cases like nullish coalescing or safe reads. The result is that while we do generate the correct variables, they're added to the creation block rather than the tracking function which causes an error at runtime.

These changes address the issue by keeping track of a separate set of ops for the track expression that are prepended to the generated function, similarly to how we handle event listeners.

Fixes #56256.

Currently when we generate the tracking expression for a `@for` block, we process its expression in the context of the creation block. This is incorrect, because the expression may require ops of its own for cases like nullish coalescing or safe reads. The result is that while we do generate the correct variable, they're added to the creation block rather than the tracking function which causes an error at runtime.

These changes address the issue by keeping track of a separate set of ops for the `track` expression that are prepended to the generated function, similarly to how we handle event listeners.

Fixes angular#56256.
@crisbeto crisbeto added action: review The PR is still awaiting reviews from at least one requested reviewer target: patch This PR is targeted for the next patch release area: compiler Issues related to `ngc`, Angular's template compiler action: global presubmit The PR is in need of a google3 global presubmit labels Nov 6, 2024
@ngbot ngbot bot added this to the Backlog milestone Nov 6, 2024
@angular-robot angular-robot bot added area: compiler Issues related to `ngc`, Angular's template compiler and removed area: compiler Issues related to `ngc`, Angular's template compiler labels Nov 6, 2024
@ngbot ngbot bot modified the milestone: Backlog Nov 6, 2024
@crisbeto
Copy link
Copy Markdown
Member Author

crisbeto commented Nov 6, 2024

Passing TGP

@crisbeto crisbeto removed the action: global presubmit The PR is in need of a google3 global presubmit label Nov 6, 2024
@crisbeto crisbeto marked this pull request as ready for review November 6, 2024 12:52
@crisbeto crisbeto requested a review from alxhub November 6, 2024 12:53
@crisbeto crisbeto requested review from mmalerba and removed request for alxhub February 11, 2025 17:49
@crisbeto crisbeto added action: merge The PR is ready for merge by the caretaker and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Feb 11, 2025
@atscott
Copy link
Copy Markdown
Contributor

atscott commented Feb 12, 2025

This PR was merged into the repository by commit 9e847fc.

The changes were merged into the following branches: main, 19.1.x

@atscott atscott closed this in 9e847fc Feb 12, 2025
atscott pushed a commit that referenced this pull request Feb 12, 2025
…les (#58520)

Currently when we generate the tracking expression for a `@for` block, we process its expression in the context of the creation block. This is incorrect, because the expression may require ops of its own for cases like nullish coalescing or safe reads. The result is that while we do generate the correct variable, they're added to the creation block rather than the tracking function which causes an error at runtime.

These changes address the issue by keeping track of a separate set of ops for the `track` expression that are prepended to the generated function, similarly to how we handle event listeners.

Fixes #56256.

PR Close #58520
@angular-automatic-lock-bot
Copy link
Copy Markdown

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Mar 15, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: merge The PR is ready for merge by the caretaker area: compiler Issues related to `ngc`, Angular's template compiler target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Exception when using null coalescing operator in @for track expression

3 participants