Skip to content

Commit 4b9be9f

Browse files
Copilotandrewbranch
andcommitted
Investigate iterator parameter validation caching issue
Co-authored-by: andrewbranch <3277153+andrewbranch@users.noreply.github.com>
1 parent 079190c commit 4b9be9f

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

internal/checker/checker.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5748,7 +5748,9 @@ 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)
57515752
iterationTypes := c.getIterationTypesOfIterable(inputType, use, core.IfElse(uplevelIteration, errorNode, nil))
5753+
fmt.Printf("DEBUG: getIterationTypesOfIterable returned yieldType=%v\n", iterationTypes.yieldType != nil)
57525754
if checkAssignability {
57535755
if iterationTypes.nextType != nil {
57545756
var diagnostic *diagnostics.Message
@@ -5769,6 +5771,7 @@ func (c *Checker) getIteratedTypeOrElementType(use IterationUse, inputType *Type
57695771
}
57705772
if iterationTypes.yieldType != nil || uplevelIteration {
57715773
if iterationTypes.yieldType == nil {
5774+
fmt.Printf("DEBUG: iterationTypes.yieldType is nil, returning nil\n")
57725775
return nil
57735776
}
57745777
if possibleOutOfBounds {
@@ -5900,10 +5903,13 @@ func (c *Checker) getIterationTypesOfIterable(t *Type, use IterationUse, errorNo
59005903
if IsTypeAny(t) {
59015904
return IterationTypes{c.anyType, c.anyType, c.anyType}
59025905
}
5906+
fmt.Printf("DEBUG: getIterationTypesOfIterable called with use=%d, errorNode=%v\n", use, errorNode != nil)
59035907
key := IterationTypesKey{typeId: t.id, use: use&IterationUseCacheFlags | core.IfElse(errorNode != nil, IterationUseReportError, 0)}
59045908
if cached, ok := c.iterationTypesCache[key]; ok {
5909+
fmt.Printf("DEBUG: getIterationTypesOfIterable cache hit\n")
59055910
return cached
59065911
}
5912+
fmt.Printf("DEBUG: getIterationTypesOfIterable cache miss\n")
59075913
result := c.getIterationTypesOfIterableWorker(t, use, errorNode)
59085914
c.iterationTypesCache[key] = result
59095915
return result

0 commit comments

Comments
 (0)