Allow impure ref initialization in render#35992
Open
angular-bootstrap wants to merge 1 commit intofacebook:mainfrom
Open
Allow impure ref initialization in render#35992angular-bootstrap wants to merge 1 commit intofacebook:mainfrom
angular-bootstrap wants to merge 1 commit intofacebook:mainfrom
Conversation
Author
|
Following up on your earlier comment, I reworked this as a compiler-side change with compiler fixture tests. This fix allows the narrow safe case of null-guarded I verified it with targeted |
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.
Summary
Allows the narrow safe case of initializing
ref.currentfrom an impure call during render when it is guarded by the standard null-check initialization pattern.This updates the compiler to recognize:
as a valid one-time ref initialization flow, while continuing to reject other impure render-time calls.
Changes
Add shared compiler analysis to detect allowed impure ref initializers.
Use that analysis in ValidateNoImpureFunctionsInRender.
Use the same analysis in InferMutationAliasingRanges so the inference path does not still surface the call as an Impure error.
Add compiler fixture coverage for the allowed case in both fixture trees.
Test Plan
Both targeted fixture runs reported the expected pass/fail behavior locally. The snap runner in this environment still exits non-zero afterward because of its existing worker shutdown bug (Farm is ended, no more calls can be done to it).
Issue
Closes #35973