fix: listener handler_expression should generate tmp variable declarations in handler scope#8
Merged
Brooooooklyn merged 2 commits intomainfrom Feb 4, 2026
Conversation
…tions in handler scope handler_expression was being processed without the IN_CHILD_OPERATION flag, causing temporary variables to be scoped to the parent create block instead of the listener function. This meant `let tmp_N_0;` declarations were missing inside listener functions that use safe navigation on function call receivers (e.g., `getPopover()?.close()`). Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
…tmp declarations handler_expression was being processed inside the per-op loop, causing it to be visited/transformed once per handler_op. When handler_ops had multiple entries (e.g., restoreView + nextContext), this produced spurious declarations (let tmp_0_0; let tmp_1_0;) and wrong variable names. Now handler_expression is processed once after the loop with op_count set to handler_ops.len(), matching Angular TS where the return expression is the last entry in handlerOps. For a listener with 2 handler_ops, this correctly generates tmp_2_0 instead of tmp_1_0. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
handler_expression was being processed without the IN_CHILD_OPERATION flag, causing temporary variables to be scoped to the parent create block instead of the listener function. This meant
let tmp_N_0;declarations were missing inside listener functions that use safe navigation on function call receivers (e.g.,getPopover()?.close()).Note
Medium Risk
Touches the compiler’s IR traversal and temporary-variable generation for event listeners, which can change emitted code and temp var naming in templates with safe navigation. Scope is narrow but could affect listener output across templates.
Overview
Fixes listener compilation so
CreateOp::Listener.handler_expressionis treated as part of the handler (child operation) scope during expression traversal, aligning visitor/transform flags withhandler_ops.Updates the
temporary_variablesphase to generate temp-variable names/declarations forhandler_expressiontogether withhandler_ops(with the correct op index ordering), ensuring safe-navigation on call receivers inside listeners emitslet tmp_N_0;inside the listener function.Adds integration tests + snapshots covering safe calls/property reads in listeners, including the embedded-view (@if) case to validate correct temp naming (
tmp_2_0).Written by Cursor Bugbot for commit ac7b95c. This will update automatically on new commits. Configure here.