Fix: Make 'use no memo' apply recursively (#35350) #35366
Closed
+1,036,121
−0
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
This PR addresses an issue where the
'use no memo'directive does not apply recursively to nested functions.When a function is marked with
'use no memo', the expected behavior is that neither the function itself nor any of its nested components or hooks should be compiled or memoized. However, the current implementation continued to traverse into the body of such functions, leading to potential compilation of nested definitions.This change updates the traverseFunction logic in the compiler to explicitly check for the
'use no memo'directive. If detected, the traversal now skips the function entirely usingfn.skip(), ensuring that it acts as a deep barrier for memoization.How did you test this change?
Verified that the compiler correctly halts traversal when the
'use no memo'directive is present.The fix relies on the standard Babel
path.skip()method within the recursion path. By invoking this when the directive is found, the compiler is prevented from visiting or optimizing any child nodes or nested function definitions, ensuring the directive's recursive intent is honored.