Skip to content

Commit 9953b71

Browse files
authored
Clear out checker-level stacks on pop (#1369)
1 parent e092266 commit 9953b71

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

internal/checker/checker.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17879,6 +17879,7 @@ func (c *Checker) pushTypeResolution(target TypeSystemEntity, propertyName TypeS
1787917879
func (c *Checker) popTypeResolution() bool {
1788017880
lastIndex := len(c.typeResolutions) - 1
1788117881
result := c.typeResolutions[lastIndex].result
17882+
c.typeResolutions[lastIndex] = TypeResolution{} // Clear the last entry to avoid memory leaks
1788217883
c.typeResolutions = c.typeResolutions[:lastIndex]
1788317884
return result
1788417885
}
@@ -29354,7 +29355,9 @@ func (c *Checker) pushContextualType(node *ast.Node, t *Type, isCache bool) {
2935429355
}
2935529356

2935629357
func (c *Checker) popContextualType() {
29357-
c.contextualInfos = c.contextualInfos[:len(c.contextualInfos)-1]
29358+
lastIndex := len(c.contextualInfos) - 1
29359+
c.contextualInfos[lastIndex] = ContextualInfo{}
29360+
c.contextualInfos = c.contextualInfos[:lastIndex]
2935829361
}
2935929362

2936029363
func (c *Checker) findContextualNode(node *ast.Node, includeCaches bool) int {
@@ -29424,7 +29427,9 @@ func (c *Checker) pushInferenceContext(node *ast.Node, context *InferenceContext
2942429427
}
2942529428

2942629429
func (c *Checker) popInferenceContext() {
29427-
c.inferenceContextInfos = c.inferenceContextInfos[:len(c.inferenceContextInfos)-1]
29430+
lastIndex := len(c.inferenceContextInfos) - 1
29431+
c.inferenceContextInfos[lastIndex] = InferenceContextInfo{}
29432+
c.inferenceContextInfos = c.inferenceContextInfos[:lastIndex]
2942829433
}
2942929434

2943029435
func (c *Checker) getInferenceContext(node *ast.Node) *InferenceContext {

0 commit comments

Comments
 (0)