Skip to content

Commit a6356cf

Browse files
Copilotandrewbranch
andcommitted
Fix iterator parameter validation caching issue for spread syntax
Co-authored-by: andrewbranch <3277153+andrewbranch@users.noreply.github.com>
1 parent 4b9be9f commit a6356cf

File tree

1 file changed

+1
-7
lines changed

1 file changed

+1
-7
lines changed

internal/checker/checker.go

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ const (
481481
IterationUseAsyncYieldStar = IterationUseAllowsSyncIterablesFlag | IterationUseAllowsAsyncIterablesFlag | IterationUseYieldStarFlag
482482
IterationUseGeneratorReturnType = IterationUseAllowsSyncIterablesFlag
483483
IterationUseAsyncGeneratorReturnType = IterationUseAllowsAsyncIterablesFlag
484-
IterationUseCacheFlags = IterationUseAllowsSyncIterablesFlag | IterationUseAllowsAsyncIterablesFlag | IterationUseForOfFlag | IterationUseReportError
484+
IterationUseCacheFlags = IterationUseAllowsSyncIterablesFlag | IterationUseAllowsAsyncIterablesFlag | IterationUseForOfFlag | IterationUseYieldStarFlag | IterationUseSpreadFlag | IterationUseDestructuringFlag | IterationUseReportError
485485
)
486486

487487
type IterationTypes struct {
@@ -5748,9 +5748,7 @@ func (c *Checker) getIteratedTypeOrElementType(use IterationUse, inputType *Type
57485748
// downlevelIteration is requested.
57495749
if uplevelIteration || downlevelIteration || allowAsyncIterables {
57505750
// We only report errors for an invalid iterable type in ES2015 or higher.
5751-
fmt.Printf("DEBUG: getIteratedTypeOrElementType calling getIterationTypesOfIterable for use=%d\n", use)
57525751
iterationTypes := c.getIterationTypesOfIterable(inputType, use, core.IfElse(uplevelIteration, errorNode, nil))
5753-
fmt.Printf("DEBUG: getIterationTypesOfIterable returned yieldType=%v\n", iterationTypes.yieldType != nil)
57545752
if checkAssignability {
57555753
if iterationTypes.nextType != nil {
57565754
var diagnostic *diagnostics.Message
@@ -5771,7 +5769,6 @@ func (c *Checker) getIteratedTypeOrElementType(use IterationUse, inputType *Type
57715769
}
57725770
if iterationTypes.yieldType != nil || uplevelIteration {
57735771
if iterationTypes.yieldType == nil {
5774-
fmt.Printf("DEBUG: iterationTypes.yieldType is nil, returning nil\n")
57755772
return nil
57765773
}
57775774
if possibleOutOfBounds {
@@ -5903,13 +5900,10 @@ func (c *Checker) getIterationTypesOfIterable(t *Type, use IterationUse, errorNo
59035900
if IsTypeAny(t) {
59045901
return IterationTypes{c.anyType, c.anyType, c.anyType}
59055902
}
5906-
fmt.Printf("DEBUG: getIterationTypesOfIterable called with use=%d, errorNode=%v\n", use, errorNode != nil)
59075903
key := IterationTypesKey{typeId: t.id, use: use&IterationUseCacheFlags | core.IfElse(errorNode != nil, IterationUseReportError, 0)}
59085904
if cached, ok := c.iterationTypesCache[key]; ok {
5909-
fmt.Printf("DEBUG: getIterationTypesOfIterable cache hit\n")
59105905
return cached
59115906
}
5912-
fmt.Printf("DEBUG: getIterationTypesOfIterable cache miss\n")
59135907
result := c.getIterationTypesOfIterableWorker(t, use, errorNode)
59145908
c.iterationTypesCache[key] = result
59155909
return result

0 commit comments

Comments
 (0)