Skip to content

Clear out checker-level stacks on pop #1369

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 8, 2025
Merged
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
9 changes: 7 additions & 2 deletions internal/checker/checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -17879,6 +17879,7 @@ func (c *Checker) pushTypeResolution(target TypeSystemEntity, propertyName TypeS
func (c *Checker) popTypeResolution() bool {
lastIndex := len(c.typeResolutions) - 1
result := c.typeResolutions[lastIndex].result
c.typeResolutions[lastIndex] = TypeResolution{} // Clear the last entry to avoid memory leaks
c.typeResolutions = c.typeResolutions[:lastIndex]
return result
}
Expand Down Expand Up @@ -29354,7 +29355,9 @@ func (c *Checker) pushContextualType(node *ast.Node, t *Type, isCache bool) {
}

func (c *Checker) popContextualType() {
c.contextualInfos = c.contextualInfos[:len(c.contextualInfos)-1]
lastIndex := len(c.contextualInfos) - 1
c.contextualInfos[lastIndex] = ContextualInfo{}
c.contextualInfos = c.contextualInfos[:lastIndex]
Comment on lines +29358 to +29360
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is honestly better written slices.Delete, which also nils things out, but, whatever

}

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

func (c *Checker) popInferenceContext() {
c.inferenceContextInfos = c.inferenceContextInfos[:len(c.inferenceContextInfos)-1]
lastIndex := len(c.inferenceContextInfos) - 1
c.inferenceContextInfos[lastIndex] = InferenceContextInfo{}
c.inferenceContextInfos = c.inferenceContextInfos[:lastIndex]
}

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