Skip to content

[compiler] Deduplicate errors between ValidateExhaustiveDependencies and ValidatePreservedManualMemoization#35917

Merged
josephsavona merged 1 commit intomainfrom
pr35917
Feb 26, 2026
Merged

[compiler] Deduplicate errors between ValidateExhaustiveDependencies and ValidatePreservedManualMemoization#35917
josephsavona merged 1 commit intomainfrom
pr35917

Conversation

@josephsavona
Copy link
Member

@josephsavona josephsavona commented Feb 26, 2026

With the recent changes to make the compiler fault tolerant and always continue through all passes, we can now sometimes report duplicative errors. Specifically, when ValidateExhaustiveDependencies finds incorrect deps for a useMemo/useCallback call, ValidatePreservedManualMemoization will generally also error for the same block, producing duplicate errors. The exhaustive deps error is strictly more informative, so if we've already reported the earlier error we don't need the later one.

This adds a hasInvalidDeps flag to StartMemoize that is set when ValidateExhaustiveDependencies produces a diagnostic. ValidatePreservedManualMemoization then skips validation for memo blocks with this flag set.

…and ValidatePreservedManualMemoization

When ValidateExhaustiveDependencies finds incorrect deps for a useMemo/useCallback call, ValidatePreservedManualMemoization later also fires for the same memo block, producing duplicate errors. The ExhaustiveDeps error is strictly more informative (names missing/extra deps, suggests a fix).

This adds a `hasInvalidDeps` flag to StartMemoize that is set when ValidateExhaustiveDependencies produces a diagnostic. ValidatePreservedManualMemoization then skips all three of its error sites for memo blocks where this flag is set.
@meta-cla meta-cla bot added the CLA Signed label Feb 26, 2026
@github-actions github-actions bot added the React Core Team Opened by a member of the React Core Team label Feb 26, 2026
@josephsavona josephsavona requested a review from mofeiZ February 26, 2026 19:27
@josephsavona
Copy link
Member Author

The lint issue is an existing issue not related to this diff

@josephsavona josephsavona merged commit 6b113b7 into main Feb 26, 2026
23 of 24 checks passed
github-actions bot pushed a commit that referenced this pull request Feb 26, 2026
…and ValidatePreservedManualMemoization (#35917)

With the recent changes to make the compiler fault tolerant and always
continue through all passes, we can now sometimes report duplicative
errors. Specifically, when `ValidateExhaustiveDependencies` finds
incorrect deps for a useMemo/useCallback call,
`ValidatePreservedManualMemoization` will generally also error for the
same block, producing duplicate errors. The exhaustive deps error is
strictly more informative, so if we've already reported the earlier
error we don't need the later one.

This adds a `hasInvalidDeps` flag to StartMemoize that is set when
ValidateExhaustiveDependencies produces a diagnostic.
ValidatePreservedManualMemoization then skips validation for memo blocks
with this flag set.

DiffTrain build for [6b113b7](6b113b7)
github-actions bot pushed a commit that referenced this pull request Feb 26, 2026
…and ValidatePreservedManualMemoization (#35917)

With the recent changes to make the compiler fault tolerant and always
continue through all passes, we can now sometimes report duplicative
errors. Specifically, when `ValidateExhaustiveDependencies` finds
incorrect deps for a useMemo/useCallback call,
`ValidatePreservedManualMemoization` will generally also error for the
same block, producing duplicate errors. The exhaustive deps error is
strictly more informative, so if we've already reported the earlier
error we don't need the later one.

This adds a `hasInvalidDeps` flag to StartMemoize that is set when
ValidateExhaustiveDependencies produces a diagnostic.
ValidatePreservedManualMemoization then skips validation for memo blocks
with this flag set.

DiffTrain build for [6b113b7](6b113b7)
Copy link
Contributor

@mofeiZ mofeiZ left a comment

Choose a reason for hiding this comment

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

thanks for fixing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed React Core Team Opened by a member of the React Core Team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants