Fix local table space for *_
We need to make sure there is enough room in the local table for repeated `*_` parameters Co-Authored-By: Matt Valentine-House <matt@eightbitraptor.com>
This commit is contained in:
parent
03f76f098a
commit
bb6af9287b
@ -6360,7 +6360,7 @@ pm_compile_node(rb_iseq_t *iseq, const pm_node_t *node, LINK_ANCHOR *const ret,
|
|||||||
// ^
|
// ^
|
||||||
if (parameters_node && parameters_node->rest) {
|
if (parameters_node && parameters_node->rest) {
|
||||||
if (!(PM_NODE_TYPE_P(parameters_node->rest, PM_IMPLICIT_REST_NODE))) {
|
if (!(PM_NODE_TYPE_P(parameters_node->rest, PM_IMPLICIT_REST_NODE))) {
|
||||||
if (!((pm_rest_parameter_node_t *)parameters_node->rest)->name) {
|
if (!((pm_rest_parameter_node_t *)parameters_node->rest)->name || PM_NODE_FLAG_P(parameters_node->rest, PM_PARAMETER_FLAGS_REPEATED_PARAMETER)) {
|
||||||
table_size++;
|
table_size++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -6497,8 +6497,14 @@ pm_compile_node(rb_iseq_t *iseq, const pm_node_t *node, LINK_ANCHOR *const ret,
|
|||||||
if (name) {
|
if (name) {
|
||||||
// def foo(a, (b, *c, d), e = 1, *f, g, (h, *i, j), k:, l: 1, **m, &n)
|
// def foo(a, (b, *c, d), e = 1, *f, g, (h, *i, j), k:, l: 1, **m, &n)
|
||||||
// ^^
|
// ^^
|
||||||
|
if (PM_NODE_FLAG_P(parameters_node->rest, PM_PARAMETER_FLAGS_REPEATED_PARAMETER)) {
|
||||||
|
ID local = pm_constant_id_lookup(scope_node, name);
|
||||||
|
local_table_for_iseq->ids[local_index] = local;
|
||||||
|
}
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
// def foo(a, (b, *c, d), e = 1, *, g, (h, *i, j), k:, l: 1, **m, &n)
|
// def foo(a, (b, *c, d), e = 1, *, g, (h, *i, j), k:, l: 1, **m, &n)
|
||||||
// ^
|
// ^
|
||||||
|
@ -1545,6 +1545,10 @@ a
|
|||||||
CODE
|
CODE
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_repeated_splat_underscore
|
||||||
|
assert_prism_eval("def self.m(_, _, _ = 1, _ = 2, *_); end; method(:m).parameters")
|
||||||
|
end
|
||||||
|
|
||||||
def test_repeated_optional_underscore
|
def test_repeated_optional_underscore
|
||||||
assert_prism_eval("def self.m(a, _, _, _ = 1, _ = 2, b); end; method(:m).parameters")
|
assert_prism_eval("def self.m(a, _, _, _ = 1, _ = 2, b); end; method(:m).parameters")
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user