Keep dependent destructuring narrowing during re-entrant checks#4606
Open
Andarist wants to merge 8 commits into
Open
Keep dependent destructuring narrowing during re-entrant checks#4606Andarist wants to merge 8 commits into
Andarist wants to merge 8 commits into
Conversation
Andarist
commented
Jul 11, 2026
Comment on lines
+13702
to
+13703
| // Guard parent-type resolution only; flow analysis should allow re-entrant narrowing | ||
| links.flags &^= NodeCheckFlagsInCheckIdentifier |
Contributor
Author
There was a problem hiding this comment.
#2542 pushed this to the latter line - and that's what broke the reported case
But now, thanks to the introduced rootInitializer check, we just never enter this entire branch. It seems to me that thanks to that we can push back this flag reset to an earlier spot (that is required to fix one of the tests I added as part of this PR)
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses #4572 by adjusting how the checker preserves dependent destructuring narrowing across re-entrant checks, and adds regression coverage around dependent destructuring scenarios (including overloaded assertion functions).
Changes:
- Update dependent destructuring narrowing logic in
Checker.getNarrowedTypeOfSymbolto avoid declaration circularity while allowing re-entrant narrowing during flow analysis. - Add a targeted regression test for overloaded assertion + correlated destructuring narrowing (issue #4572).
- Add additional dependent destructuring coverage (cross-file, deferred callbacks, binding element initializer) and conformance “no crash”/reference baselines for related upstream issues.
Reviewed changes
Copilot reviewed 32 out of 32 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| internal/checker/checker.go | Adjusts dependent destructuring narrowing/recursion-guard behavior during re-entrant checks. |
| testdata/tests/cases/compiler/controlFlowDependentDestructuringOverloadedAssertion.ts | Regression for #4572 (overloaded assertion + correlated destructuring). |
| testdata/tests/cases/compiler/dependentDestructuringBindingElementInitializer.ts | Compiler test for dependent destructuring behavior in binding element initializers. |
| testdata/tests/cases/compiler/dependentDestructuringCrossFilePosition.ts | Compiler test ensuring dependent destructuring narrowing works across files. |
| testdata/tests/cases/compiler/dependentDestructuringDeferredCallback.ts | Compiler test ensuring narrowing is preserved into deferred callbacks. |
| testdata/tests/cases/conformance/controlFlow/dependentDestructuredVariablesNoCrash1.ts | Conformance regression to ensure dependent destructuring does not crash (upstream issue). |
| testdata/tests/cases/conformance/controlFlow/dependentDestructuredVariablesNoCrash2.ts | Conformance regression to ensure dependent destructuring does not crash (upstream issue). |
| testdata/tests/cases/conformance/controlFlow/dependentDestructuredVariablesNoCrash3.ts | Conformance regression to ensure dependent destructuring does not crash (upstream issue). |
| testdata/tests/cases/conformance/controlFlow/dependentDestructuredVariablesRefereinceInDeclaration1.ts | Conformance coverage for dependent destructured variable references in declarations (upstream issue). |
| testdata/baselines/reference/compiler/controlFlowDependentDestructuringOverloadedAssertion.symbols | Symbols baseline for the #4572 regression test. |
| testdata/baselines/reference/compiler/controlFlowDependentDestructuringOverloadedAssertion.types | Types baseline for the #4572 regression test. |
| testdata/baselines/reference/compiler/dependentDestructuringBindingElementInitializer.symbols | Symbols baseline for binding element initializer dependent destructuring. |
| testdata/baselines/reference/compiler/dependentDestructuringBindingElementInitializer.types | Types baseline for binding element initializer dependent destructuring. |
| testdata/baselines/reference/compiler/dependentDestructuringCrossFilePosition.symbols | Symbols baseline for cross-file dependent destructuring test. |
| testdata/baselines/reference/compiler/dependentDestructuringCrossFilePosition.types | Types baseline for cross-file dependent destructuring test. |
| testdata/baselines/reference/compiler/dependentDestructuringDeferredCallback.symbols | Symbols baseline for deferred callback dependent destructuring test. |
| testdata/baselines/reference/compiler/dependentDestructuringDeferredCallback.types | Types baseline for deferred callback dependent destructuring test. |
| testdata/baselines/reference/conformance/dependentDestructuredVariablesNoCrash1.errors.txt | Error baseline for conformance no-crash case #1. |
| testdata/baselines/reference/conformance/dependentDestructuredVariablesNoCrash1.js | JS baseline for conformance no-crash case #1. |
| testdata/baselines/reference/conformance/dependentDestructuredVariablesNoCrash1.symbols | Symbols baseline for conformance no-crash case #1. |
| testdata/baselines/reference/conformance/dependentDestructuredVariablesNoCrash1.types | Types baseline for conformance no-crash case #1. |
| testdata/baselines/reference/conformance/dependentDestructuredVariablesNoCrash2.errors.txt | Error baseline for conformance no-crash case #2. |
| testdata/baselines/reference/conformance/dependentDestructuredVariablesNoCrash2.js | JS baseline for conformance no-crash case #2. |
| testdata/baselines/reference/conformance/dependentDestructuredVariablesNoCrash2.symbols | Symbols baseline for conformance no-crash case #2. |
| testdata/baselines/reference/conformance/dependentDestructuredVariablesNoCrash2.types | Types baseline for conformance no-crash case #2. |
| testdata/baselines/reference/conformance/dependentDestructuredVariablesNoCrash3.errors.txt | Error baseline for conformance no-crash case #3. |
| testdata/baselines/reference/conformance/dependentDestructuredVariablesNoCrash3.js | JS baseline for conformance no-crash case #3. |
| testdata/baselines/reference/conformance/dependentDestructuredVariablesNoCrash3.symbols | Symbols baseline for conformance no-crash case #3. |
| testdata/baselines/reference/conformance/dependentDestructuredVariablesNoCrash3.types | Types baseline for conformance no-crash case #3. |
| testdata/baselines/reference/conformance/dependentDestructuredVariablesRefereinceInDeclaration1.errors.txt | Error baseline for “reference in declaration” conformance case. |
| testdata/baselines/reference/conformance/dependentDestructuredVariablesRefereinceInDeclaration1.symbols | Symbols baseline for “reference in declaration” conformance case. |
| testdata/baselines/reference/conformance/dependentDestructuredVariablesRefereinceInDeclaration1.types | Types baseline for “reference in declaration” conformance case. |
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.
fixes #4572
fixes #4613