[PRISM] Do not send numbered parameters into eval

This commit is contained in:
Kevin Newton 2024-03-13 15:47:40 -04:00
parent 2f8cbd6431
commit 00c32f606a

View File

@ -1682,8 +1682,20 @@ pm_eval_make_iseq(VALUE src, VALUE fname, int line,
for (int local_index = 0; local_index < locals_count; local_index++) {
pm_string_t *scope_local = &options_scope->locals[local_index];
const char *name = rb_id2name(ISEQ_BODY(iseq)->local_table[local_index]);
if (name) pm_string_constant_init(scope_local, name, strlen(name));
ID local = ISEQ_BODY(iseq)->local_table[local_index];
if (rb_is_local_id(local)) {
const char *name = rb_id2name(local);
size_t length = strlen(name);
// Explicitly skip numbered parameters. These should not be sent
// into the eval.
if (length == 2 && name[0] == '_' && name[1] >= '1' && name[1] <= '9') {
continue;
}
pm_string_constant_init(scope_local, name, strlen(name));
}
}
iseq = ISEQ_BODY(iseq)->parent_iseq;