зеркало из https://github.com/github/ruby.git
Fix repeated block param
Co-Authored-By: Matt Valentine-House <matt@eightbitraptor.com>
This commit is contained in:
Родитель
1817af5074
Коммит
94f3f9502c
|
@ -6399,6 +6399,12 @@ pm_compile_node(rb_iseq_t *iseq, const pm_node_t *node, LINK_ANCHOR *const ret,
|
||||||
table_size++;
|
table_size++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (parameters_node && parameters_node->block) {
|
||||||
|
if (PM_NODE_FLAG_P(parameters_node->block, PM_PARAMETER_FLAGS_REPEATED_PARAMETER)) {
|
||||||
|
table_size++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// When we have a `...` as the keyword_rest, it's a forwarding_parameter_node and
|
// When we have a `...` as the keyword_rest, it's a forwarding_parameter_node and
|
||||||
// we need to leave space for 2 more locals on the locals table (`*` and `&`)
|
// we need to leave space for 2 more locals on the locals table (`*` and `&`)
|
||||||
if (parameters_node && parameters_node->keyword_rest &&
|
if (parameters_node && parameters_node->keyword_rest &&
|
||||||
|
@ -6747,14 +6753,20 @@ pm_compile_node(rb_iseq_t *iseq, const pm_node_t *node, LINK_ANCHOR *const ret,
|
||||||
body->param.flags.has_block = true;
|
body->param.flags.has_block = true;
|
||||||
|
|
||||||
pm_constant_id_t name = ((pm_block_parameter_node_t *)parameters_node->block)->name;
|
pm_constant_id_t name = ((pm_block_parameter_node_t *)parameters_node->block)->name;
|
||||||
|
|
||||||
if (name == 0) {
|
if (name == 0) {
|
||||||
local_table_for_iseq->ids[local_index] = PM_CONSTANT_AND;
|
local_table_for_iseq->ids[local_index] = PM_CONSTANT_AND;
|
||||||
st_insert(index_lookup_table, PM_CONSTANT_AND, local_index);
|
st_insert(index_lookup_table, PM_CONSTANT_AND, local_index);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
if (PM_NODE_FLAG_P(parameters_node->block, PM_PARAMETER_FLAGS_REPEATED_PARAMETER)) {
|
||||||
|
ID local = pm_constant_id_lookup(scope_node, name);
|
||||||
|
local_table_for_iseq->ids[local_index] = local;
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
pm_insert_local_index(name, local_index, index_lookup_table, local_table_for_iseq, scope_node);
|
pm_insert_local_index(name, local_index, index_lookup_table, local_table_for_iseq, scope_node);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
local_index++;
|
local_index++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1545,6 +1545,10 @@ a
|
||||||
CODE
|
CODE
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_repeated_block_underscore
|
||||||
|
assert_prism_eval("def self.m(_, **_, &_); _; end; method(:m).parameters")
|
||||||
|
end
|
||||||
|
|
||||||
def test_repeated_kw_rest_underscore
|
def test_repeated_kw_rest_underscore
|
||||||
assert_prism_eval("def self.m(_, **_); _; end; method(:m).parameters")
|
assert_prism_eval("def self.m(_, **_); _; end; method(:m).parameters")
|
||||||
end
|
end
|
||||||
|
|
Загрузка…
Ссылка в новой задаче