Skip to content

Commit ac20851

Browse files
Update internal/checker/inference.go
Co-authored-by: Copilot <[email protected]>
1 parent 71a1379 commit ac20851

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

internal/checker/inference.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1666,6 +1666,10 @@ func (c *Checker) inferFromLiteralToIndexedAccess(n *InferenceState, source *Typ
16661666
if c.isTypeIdenticalTo(source, memberIndexedType) {
16671667
// Found a match! Infer this union member as a candidate for the type parameter
16681668
candidate := unionMember
1669+
// Prevent inferring the blocked string type as a candidate.
1670+
// This type is used as a sentinel to represent cases where string inference should not occur,
1671+
// such as when a string index signature would lead to overly broad or incorrect inference.
1672+
// Blocking it here avoids unsound or unintended type inference results.
16691673
if candidate == c.blockedStringType {
16701674
return
16711675
}

0 commit comments

Comments
 (0)