diff options
author | Nobuyoshi Nakada <[email protected]> | 2021-10-13 16:48:35 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <[email protected]> | 2021-11-07 12:40:27 +0900 |
commit | ec657f44dca3b84fde2a0b3b66c4e0e74a4cdce8 (patch) | |
tree | 88d9917508840b254cd1809ff07fec43a0b0323d /vm.c | |
parent | 334b69e5042f47f89c8780c1d7efa32d70c84786 (diff) |
Refine the error message for hidden variables
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/5035
Diffstat (limited to 'vm.c')
-rw-r--r-- | vm.c | 11 |
1 files changed, 8 insertions, 3 deletions
@@ -1035,9 +1035,14 @@ env_copy(const VALUE *src_ep, VALUE read_only_variables) if (id == src_env->iseq->body->local_table[j]) { VALUE v = src_env->env[j]; if (!rb_ractor_shareable_p(v)) { - rb_raise(rb_eRactorIsolationError, - "can not make shareable Proc because it can refer unshareable object %" - "+" PRIsVALUE " from variable `%" PRIsVALUE "'", v, rb_id2str(id)); + VALUE name = rb_id2str(id); + VALUE msg = rb_sprintf("can not make shareable Proc because it can refer" + " unshareable object %+" PRIsVALUE " from ", v); + if (name) + rb_str_catf(msg, "variable `%" PRIsVALUE "'", name); + else + rb_str_cat_cstr(msg, "a hidden variable"); + rb_exc_raise(rb_exc_new_str(rb_eRactorIsolationError, msg)); } env_body[j] = v; rb_ary_delete_at(read_only_variables, i); |