summaryrefslogtreecommitdiff
path: root/vm_eval.c
diff options
context:
space:
mode:
authorKevin Newton <[email protected]>2024-03-13 15:47:40 -0400
committerKevin Newton <[email protected]>2024-03-13 19:01:43 -0400
commit00c32f606adfa30552fdd1a1be3e301dde00963b (patch)
treeada1128b0e6ec3eb0866d06dc93eea03228a7d18 /vm_eval.c
parent2f8cbd6431016cf3498b0f26e56d3d5b214b58b0 (diff)
[PRISM] Do not send numbered parameters into eval
Diffstat (limited to 'vm_eval.c')
-rw-r--r--vm_eval.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/vm_eval.c b/vm_eval.c
index 2a5bba6998..f7e23a691b 100644
--- a/vm_eval.c
+++ b/vm_eval.c
@@ -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;