Repository navigation
Fix indexed-access base constraint losing explicit bound across checker histories - #65520
Open
刘亦达 (zhengdaodeguL) wants to merge 1 commit into
Conversation
This branch has not been deployed
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.
Checking files in sequence with a retained checker could lose the explicit
bound of a type parameter through a finite indexed-access chain, producing a
false TS2339 that depends on check order:
a.ts → b.tsreported TS2339 onx.b;b.ts → a.tsandb.tsalone didnot. The cause is in
getResolvedBaseConstraint: indexed-access recursionidentity was unwrapped to its object, so the ten-level chain could reach the
explicit type parameter at the heuristic cutoff and turn a recursion-context
cutoff into a permanent
noConstraintTypeanswer.This PR narrows the stack identity for that case only: when the type is an
indexed access and the existing mapped-type normalization resolves to a type
parameter, the recursion stack uses that normalized parameter's type
identity instead of its symbol. Shared relation/inference identities,
non-parameter targets, cache policy, exact cycle detection, and depth
bounds are untouched.
Added
TestBaseConstraintHistory(a retained-checker integration test withinline fixtures) covering both positive cases in all three histories plus
the negative controls: a missing property still reports TS2339, a wrong
return type still reports TS2322, and an exact self-constraint cycle still
reports TS2313 and terminates. On the base commit, exactly the two reported
a → bhistories fail; with the fix, all 12 subtests pass.go test ./internal/checker/... ./internal/compiler/...and the fullTestLocalsuite pass.
Credit: this fix and its test adaptation come from the issue reporter's
research. Petr Glaser (@BleedingDev) (report filed by GPT-6.1 Sol on their behalf)
validated the narrow patch in their own repository — 19 history/control
cases plus full
TestLocalconformance — and explicitly left it "not areleased fix or an upstream PR", retaining the patch and tests for human
review. The patch applied here is their candidate verbatim:
https://github.com/BleedingDev/tsrs/blob/b2655bf774ecd6ae51cea37615a81d92c07a3825/tools/oracle/base-constraint-history/indexed-access-identity.patch
(validation run https://github.com/BleedingDev/tsrs/actions/runs/43655580941).
The reporter also verified that the order-independence draft #65064 does
not correctly fix this regression, so this narrow fix stands on its own.
Fixes #65508.