Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions internal/checker/inference.go
Original file line number Diff line number Diff line change
Expand Up @@ -348,10 +348,10 @@ func (c *Checker) invokeOnce(n *InferenceState, source *Type, target *Type, acti
saveExpandingFlags := n.expandingFlags
n.sourceStack = append(n.sourceStack, source)
n.targetStack = append(n.targetStack, target)
if c.isDeeplyNestedType(source, n.sourceStack, 2) {
if c.isDeeplyNestedType(source, n.sourceStack, 200) {
n.expandingFlags |= ExpandingFlagsSource
}
if c.isDeeplyNestedType(target, n.targetStack, 2) {
if c.isDeeplyNestedType(target, n.targetStack, 200) {
n.expandingFlags |= ExpandingFlagsTarget
}
if n.expandingFlags != ExpandingFlagsBoth {
Expand Down Expand Up @@ -1002,10 +1002,10 @@ func (c *Checker) inferReverseMappedType(source *Type, target *Type, constraint
c.reverseMappedSourceStack = append(c.reverseMappedSourceStack, source)
c.reverseMappedTargetStack = append(c.reverseMappedTargetStack, target)
saveExpandingFlags := c.reverseExpandingFlags
if c.isDeeplyNestedType(source, c.reverseMappedSourceStack, 2) {
if c.isDeeplyNestedType(source, c.reverseMappedSourceStack, 200) {
c.reverseExpandingFlags |= ExpandingFlagsSource
}
if c.isDeeplyNestedType(target, c.reverseMappedTargetStack, 2) {
if c.isDeeplyNestedType(target, c.reverseMappedTargetStack, 200) {
c.reverseExpandingFlags |= ExpandingFlagsTarget
}
var t *Type
Expand Down
12 changes: 6 additions & 6 deletions internal/checker/relater.go
Original file line number Diff line number Diff line change
Expand Up @@ -3061,13 +3061,13 @@ func (r *Relater) recursiveTypeRelatedTo(source *Type, target *Type, reportError
saveExpandingFlags := r.expandingFlags
if recursionFlags&RecursionFlagsSource != 0 {
r.sourceStack = append(r.sourceStack, source)
if r.expandingFlags&ExpandingFlagsSource == 0 && r.c.isDeeplyNestedType(source, r.sourceStack, 3) {
if r.expandingFlags&ExpandingFlagsSource == 0 && r.c.isDeeplyNestedType(source, r.sourceStack, 300) {
r.expandingFlags |= ExpandingFlagsSource
}
}
if recursionFlags&RecursionFlagsTarget != 0 {
r.targetStack = append(r.targetStack, target)
if r.expandingFlags&ExpandingFlagsTarget == 0 && r.c.isDeeplyNestedType(target, r.targetStack, 3) {
if r.expandingFlags&ExpandingFlagsTarget == 0 && r.c.isDeeplyNestedType(target, r.targetStack, 300) {
r.expandingFlags |= ExpandingFlagsTarget
}
}
Expand Down Expand Up @@ -3483,9 +3483,9 @@ func (r *Relater) structuredTypeRelatedToWorker(source *Type, target *Type, repo
}
}
case target.flags&TypeFlagsConditional != 0:
// If we reach 10 levels of nesting for the same conditional type, assume it is an infinitely expanding recursive
// If we reach 1000 levels of nesting for the same conditional type, assume it is an infinitely expanding recursive
// conditional type and bail out with a Ternary.Maybe result.
if r.c.isDeeplyNestedType(target, r.targetStack, 10) {
if r.c.isDeeplyNestedType(target, r.targetStack, 1000) {
return TernaryMaybe
}
c := target.AsConditionalType()
Expand Down Expand Up @@ -3664,9 +3664,9 @@ func (r *Relater) structuredTypeRelatedToWorker(source *Type, target *Type, repo
}
}
case source.flags&TypeFlagsConditional != 0:
// If we reach 10 levels of nesting for the same conditional type, assume it is an infinitely expanding recursive
// If we reach 1000 levels of nesting for the same conditional type, assume it is an infinitely expanding recursive
// conditional type and bail out with a Ternary.Maybe result.
if r.c.isDeeplyNestedType(source, r.sourceStack, 10) {
if r.c.isDeeplyNestedType(source, r.sourceStack, 1000) {
return TernaryMaybe
}
if target.flags&TypeFlagsConditional != 0 {
Expand Down
Loading