Skip to content

Conversation

@crisbeto
Copy link
Member

Includes the following fixes related to @let:

fix(compiler-cli): type check let declarations nested inside nodes

Fixes that we were only capturing @let declarations at the top level of the scope, not any of the nested children.

fix(compiler-cli): flag all conflicts between let declarations and local symbols

Expands the check around conflicting @let declarations to also cover template variables and local references.

fix(compiler): give precedence to local let declarations over parent ones

Currently the logic that maps a name to a variable looks at the variables in their definition order. This means that @let declarations from parent views will always come before local ones, because the local ones are declared inline whereas the parent ones are hoisted to the top of the function.

These changes resolve the issue by giving precedence to the local variables.

Fixes #56737.

Fixes that we were only capturing `@let` declarations at the top level of the scope, not any of the nested children.
@crisbeto crisbeto added action: review The PR is still awaiting reviews from at least one requested reviewer area: compiler Issues related to `ngc`, Angular's template compiler target: minor This PR is targeted for the next minor release labels Jun 28, 2024
@ngbot ngbot bot added this to the Backlog milestone Jun 28, 2024
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that this is the most elegant way of solving it, but I think it's likely the most future-proof. Some alternatives that were considered, but didn't work:

  1. Iterating the instructions in reverse seems to break cases where variables depend on other variables. Otherwise this would've been the simplest.
  2. We can't hoist the local @let variables to the top, because they need an advance call.

@crisbeto crisbeto marked this pull request as ready for review June 28, 2024 13:07
@pullapprove pullapprove bot requested a review from thePunderWoman June 28, 2024 16:48
Copy link
Contributor

@thePunderWoman thePunderWoman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reviewed-for: public-api

@pullapprove pullapprove bot requested a review from atscott June 28, 2024 17:11
Copy link
Contributor

@atscott atscott left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reviewed-for: public-api

@crisbeto crisbeto added the action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews label Jun 28, 2024
@crisbeto crisbeto self-assigned this Jun 28, 2024
@crisbeto crisbeto removed the action: review The PR is still awaiting reviews from at least one requested reviewer label Jun 28, 2024
…cal symbols

Expands the check around conflicting `@let` declarations to also cover template variables and local references.
@crisbeto crisbeto added action: merge The PR is ready for merge by the caretaker and removed action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews labels Jun 28, 2024
@crisbeto crisbeto removed their assignment Jun 28, 2024
…ones

Currently the logic that maps a name to a variable looks at the variables in their definition order. This means that `@let` declarations from parent views will always come before local ones, because the local ones are declared inline whereas the parent ones are hoisted to the top of the function.

These changes resolve the issue by giving precedence to the local variables.

Fixes angular#56737.
thePunderWoman pushed a commit that referenced this pull request Jul 1, 2024
…cal symbols (#56752)

Expands the check around conflicting `@let` declarations to also cover template variables and local references.

PR Close #56752
thePunderWoman pushed a commit that referenced this pull request Jul 1, 2024
…ones (#56752)

Currently the logic that maps a name to a variable looks at the variables in their definition order. This means that `@let` declarations from parent views will always come before local ones, because the local ones are declared inline whereas the parent ones are hoisted to the top of the function.

These changes resolve the issue by giving precedence to the local variables.

Fixes #56737.

PR Close #56752
@thePunderWoman
Copy link
Contributor

This PR was merged into the repository by commit 2a1291e.

The changes were merged into the following branches: main

@angular-automatic-lock-bot
Copy link

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 Aug 1, 2024
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: minor This PR is targeted for the next minor release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

@let Bug -- should give precedence to a local let declaration over one from a parent view

5 participants