diff options
Diffstat (limited to 'proc.c')
-rw-r--r-- | proc.c | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -499,6 +499,12 @@ bind_local_variables(VALUE bindval) return rb_vm_env_local_variables(env); } +int +rb_numparam_id_p(ID id) +{ + return (tNUMPARAM_1 << ID_SCOPE_SHIFT) <= id && id < ((tNUMPARAM_1 + 10) << ID_SCOPE_SHIFT); +} + /* * call-seq: * binding.local_variable_get(symbol) -> obj @@ -525,6 +531,10 @@ bind_local_variable_get(VALUE bindval, VALUE sym) const rb_env_t *env; if (!lid) goto undefined; + if (rb_numparam_id_p(lid)) { + rb_name_err_raise("numbered parameter '%1$s' is not a local variable", + bindval, ID2SYM(lid)); + } GetBindingPtr(bindval, bind); @@ -574,6 +584,10 @@ bind_local_variable_set(VALUE bindval, VALUE sym, VALUE val) const rb_env_t *env; if (!lid) lid = rb_intern_str(sym); + if (rb_numparam_id_p(lid)) { + rb_name_err_raise("numbered parameter '%1$s' is not a local variable", + bindval, ID2SYM(lid)); + } GetBindingPtr(bindval, bind); env = VM_ENV_ENVVAL_PTR(vm_block_ep(&bind->block)); |