Fix required positional repeated _ parameters

Co-Authored-By: Matt Valentine-House <matt@eightbitraptor.com>
This commit is contained in:
Aaron Patterson 2024-01-23 12:55:00 -08:00 коммит произвёл Aaron Patterson
Родитель 44c337a397
Коммит 29c3ec3d49
2 изменённых файлов: 9 добавлений и 1 удалений

Просмотреть файл

@ -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;

Просмотреть файл

@ -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