зеркало из https://github.com/github/ruby.git
Fix local table size and index for required post underscore
Co-Authored-By: Matt Valentine-House <matt@eightbitraptor.com>
This commit is contained in:
Родитель
bb6af9287b
Коммит
8b7e78f156
|
@ -6372,7 +6372,7 @@ pm_compile_node(rb_iseq_t *iseq, const pm_node_t *node, LINK_ANCHOR *const ret,
|
|||
// additional anonymous local not represented in the locals table
|
||||
// We want to account for this in our table size
|
||||
pm_node_t *required = posts_list->nodes[i];
|
||||
if (PM_NODE_TYPE_P(required, PM_MULTI_TARGET_NODE)) {
|
||||
if (PM_NODE_TYPE_P(required, PM_MULTI_TARGET_NODE) || PM_NODE_FLAG_P(required, PM_PARAMETER_FLAGS_REPEATED_PARAMETER)) {
|
||||
table_size++;
|
||||
}
|
||||
}
|
||||
|
@ -6541,8 +6541,14 @@ 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 *)post_node;
|
||||
if (PM_NODE_FLAG_P(param, 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);
|
||||
pm_insert_local_index(param->name, local_index, index_lookup_table, local_table_for_iseq, scope_node);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
|
|
|
@ -1545,6 +1545,10 @@ a
|
|||
CODE
|
||||
end
|
||||
|
||||
def test_repeated_required_post_underscore
|
||||
assert_prism_eval("def self.m(_, _, *_, _); _; end; method(:m).parameters")
|
||||
end
|
||||
|
||||
def test_repeated_splat_underscore
|
||||
assert_prism_eval("def self.m(_, _, _ = 1, _ = 2, *_); end; method(:m).parameters")
|
||||
end
|
||||
|
|
Загрузка…
Ссылка в новой задаче