Skip to content

Fix lambda closure scope ordering#161

Merged
jduhamel merged 1 commit into
developfrom
bug/lambda-ordering
May 25, 2026
Merged

Fix lambda closure scope ordering#161
jduhamel merged 1 commit into
developfrom
bug/lambda-ordering

Conversation

@jduhamel
Copy link
Copy Markdown
Collaborator

@jduhamel jduhamel commented May 25, 2026

Summary

  • fix closure-backed lambda calls so captured lexical bindings take precedence over caller-scope bindings
  • add a regression for same-named higher-order function parameters shadowing a closure variable

Verification

  • make lint
  • make test
  • go tool cover -func=test/cov.out => 96.5%

@jduhamel jduhamel marked this pull request as ready for review May 25, 2026 15:13
Comment thread lambda.go Outdated
ss := s.NewScope()
if lam.Closure != nil {
ss.parents = append(ss.parents, lam.Closure)
ss.parents = []*Scope{lam.Closure}
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Doesn't this remove the parent scopes? I think append([]*Scope{lam.Closure}, ss.parents...) would be more correct.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

updated and testcased.

@jduhamel jduhamel force-pushed the bug/lambda-ordering branch from ec4c993 to c70c4ee Compare May 25, 2026 15:27
@jduhamel jduhamel merged commit aab0263 into develop May 25, 2026
3 checks passed
@jduhamel jduhamel deleted the bug/lambda-ordering branch May 25, 2026 15:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants