Commit 49161db
Fix lambda default capture missing enclosing cell
The cell-var pre-pass merged a lambda's default expressions into its body
reference set and then filtered by the lambda's own parameter names. A name
referenced inside a default that coincided with a lambda param (e.g.
`lambda x=(lambda: x): x()`) was dropped, so the enclosing variable was never
promoted to a cell — the owner compiled it as a plain local while the nested
closure expected a cell, crashing with "MakeClosure: expected cell reference
on stack".
Defaults are evaluated in the enclosing scope, so a capture inside them must
resolve against the enclosing variable regardless of the lambda's params. Scan
lambda defaults separately and unconditionally, mirroring the FunctionDef
branch; keep param filtering only for body references.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent 954a6a8 commit 49161db
2 files changed
Lines changed: 55 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2685 | 2685 | | |
2686 | 2686 | | |
2687 | 2687 | | |
2688 | | - | |
| 2688 | + | |
| 2689 | + | |
| 2690 | + | |
| 2691 | + | |
| 2692 | + | |
| 2693 | + | |
| 2694 | + | |
| 2695 | + | |
| 2696 | + | |
| 2697 | + | |
| 2698 | + | |
| 2699 | + | |
| 2700 | + | |
| 2701 | + | |
| 2702 | + | |
| 2703 | + | |
| 2704 | + | |
| 2705 | + | |
2689 | 2706 | | |
2690 | 2707 | | |
2691 | 2708 | | |
2692 | | - | |
2693 | | - | |
2694 | | - | |
2695 | | - | |
2696 | 2709 | | |
2697 | 2710 | | |
2698 | 2711 | | |
2699 | 2712 | | |
2700 | | - | |
2701 | | - | |
2702 | | - | |
2703 | | - | |
2704 | | - | |
| 2713 | + | |
| 2714 | + | |
| 2715 | + | |
2705 | 2716 | | |
2706 | 2717 | | |
2707 | 2718 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
358 | 358 | | |
359 | 359 | | |
360 | 360 | | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
0 commit comments