зеркало из https://github.com/github/ruby.git
Fix required positional repeated _ parameters
Co-Authored-By: Matt Valentine-House <matt@eightbitraptor.com>
This commit is contained in:
Родитель
44c337a397
Коммит
29c3ec3d49
|
@ -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
|
||||
|
|
Загрузка…
Ссылка в новой задаче