Commit c98155c
committed
Fix self-recursive generic function call with explicit type args
namedFuncDecl registered a top-level generic function in the
generic-func registry only AFTER compiling its body. hasGenericFunc(name)
is what lets the expression compiler recognize name[T](...) as a
generic call rather than an indexing expression, so a self-recursive
call using explicit type args inside that same body (a common pattern
for generic recursive functions) was misparsed as indexing — evaluating
T as a nonexistent runtime variable and panicking with NotDefined.
Fixed by registering the generic function before compiling its body,
so a self-recursive call sees it already registered.1 parent 4aaad6c commit c98155c
2 files changed
Lines changed: 35 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3998 | 3998 | | |
3999 | 3999 | | |
4000 | 4000 | | |
| 4001 | + | |
| 4002 | + | |
| 4003 | + | |
| 4004 | + | |
| 4005 | + | |
| 4006 | + | |
| 4007 | + | |
| 4008 | + | |
| 4009 | + | |
| 4010 | + | |
| 4011 | + | |
| 4012 | + | |
| 4013 | + | |
| 4014 | + | |
| 4015 | + | |
| 4016 | + | |
| 4017 | + | |
| 4018 | + | |
| 4019 | + | |
| 4020 | + | |
4001 | 4021 | | |
4002 | 4022 | | |
4003 | 4023 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
402 | 402 | | |
403 | 403 | | |
404 | 404 | | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
405 | 419 | | |
406 | 420 | | |
407 | 421 | | |
| |||
428 | 442 | | |
429 | 443 | | |
430 | 444 | | |
431 | | - | |
432 | | - | |
433 | | - | |
434 | | - | |
435 | | - | |
| 445 | + | |
436 | 446 | | |
437 | 447 | | |
438 | 448 | | |
| |||
0 commit comments