diff options
author | Kevin Newton <[email protected]> | 2024-03-13 15:47:40 -0400 |
---|---|---|
committer | Kevin Newton <[email protected]> | 2024-03-13 19:01:43 -0400 |
commit | 00c32f606adfa30552fdd1a1be3e301dde00963b (patch) | |
tree | ada1128b0e6ec3eb0866d06dc93eea03228a7d18 /vm_eval.c | |
parent | 2f8cbd6431016cf3498b0f26e56d3d5b214b58b0 (diff) |
[PRISM] Do not send numbered parameters into eval
Diffstat (limited to 'vm_eval.c')
-rw-r--r-- | vm_eval.c | 16 |
1 files changed, 14 insertions, 2 deletions
@@ -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; |