diff options
| author | Aaron Patterson <tenderlove@ruby-lang.org> | 2024-01-23 12:55:00 -0800 |
|---|---|---|
| committer | Aaron Patterson <aaron.patterson@gmail.com> | 2024-01-24 12:04:44 -0800 |
| commit | 29c3ec3d49ad66c4ec9ea13735481cca598bcbcd (patch) | |
| tree | 9be3b72d6d9879d60a6255fbc4add56e842ae6f4 | |
| parent | 44c337a397b1159c7bc843a501d6a0a51e65430f (diff) | |
Fix required positional repeated _ parameters
Co-Authored-By: Matt Valentine-House <matt@eightbitraptor.com>
| -rw-r--r-- | prism_compile.c | 6 | ||||
| -rw-r--r-- | test/ruby/test_compile_prism.rb | 4 |
2 files changed, 9 insertions, 1 deletions
diff --git a/prism_compile.c b/prism_compile.c index b88d90bae0..4e2984c065 100644 --- a/prism_compile.c +++ b/prism_compile.c @@ -6431,7 +6431,11 @@ pm_compile_node(rb_iseq_t *iseq, const pm_node_t *node, LINK_ANCHOR *const ret, case PM_REQUIRED_PARAMETER_NODE: { pm_required_parameter_node_t * param = (pm_required_parameter_node_t *)required; - if (!PM_NODE_FLAG_P(required, PM_PARAMETER_FLAGS_REPEATED_PARAMETER)) { + if (PM_NODE_FLAG_P(required, PM_PARAMETER_FLAGS_REPEATED_PARAMETER)) { + ID local = pm_constant_id_lookup(scope_node, param->name); + local_table_for_iseq->ids[local_index] = local; + } + else { pm_insert_local_index(param->name, local_index, index_lookup_table, local_table_for_iseq, scope_node); } break; diff --git a/test/ruby/test_compile_prism.rb b/test/ruby/test_compile_prism.rb index 5ed41569f5..bccc4d4695 100644 --- a/test/ruby/test_compile_prism.rb +++ b/test/ruby/test_compile_prism.rb @@ -1545,6 +1545,10 @@ a CODE end + def test_repeated_required_underscore + assert_prism_eval("def self.m(a, _, _, b); end; method(:m).parameters") + end + def test_locals_in_parameters assert_prism_eval("def self.m(a = b = c = 1); [a, b, c]; end; self.m") end |
