Commit 00c8f82
committed
Fix NoMethodError in CallBaseNode#modified_vars for anonymous rest
Since ff8a516, anonymous rest arguments (bare `*`) are represented as
`nil` placeholders in `@positional_args` instead of `DummyNilNode`.
However, `CallBaseNode#modified_vars` iterates the positional args
array without skipping nil, raising NoMethodError when a call with
anonymous rest forwarding appears inside a branch (e.g.
`if cond; bar(*); end`) whose `modified_vars` is walked from
`BranchNode#install0`.
Use safe navigation so nil placeholders are skipped, matching how
`each_subnode` already guards against nil subnodes. Add a regression
case to scenario/args/anonymous_rest.rb.1 parent 283b5d9 commit 00c8f82
2 files changed
Lines changed: 8 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
247 | 247 | | |
248 | 248 | | |
249 | 249 | | |
250 | | - | |
| 250 | + | |
251 | 251 | | |
252 | 252 | | |
253 | 253 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
10 | 16 | | |
11 | 17 | | |
12 | 18 | | |
13 | 19 | | |
14 | 20 | | |
15 | 21 | | |
| 22 | + | |
16 | 23 | | |
0 commit comments