diff options
author | Koichi Sasada <[email protected]> | 2021-11-25 15:57:36 +0900 |
---|---|---|
committer | Koichi Sasada <[email protected]> | 2021-11-26 10:56:03 +0900 |
commit | e984c2a9ea29fa17c5f55d324d181f8eaa677d69 (patch) | |
tree | fdcf889e707ffe09943d0902e30ed4de9dc2c1d0 /vm_eval.c | |
parent | f3320f164fd4147256227271b89e02522a536093 (diff) |
fix to choose correct callcache
It should retun general `cc`, not for overloaded (mandatory only)
method call cache.
This issue is reported by @shugo and @ktou
https://twitter.com/shugomaeda/status/1463699797182119936
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/5173
Diffstat (limited to 'vm_eval.c')
-rw-r--r-- | vm_eval.c | 13 |
1 files changed, 9 insertions, 4 deletions
@@ -382,7 +382,7 @@ static inline enum method_missing_reason rb_method_call_status(rb_execution_cont static const struct rb_callcache * cc_new(VALUE klass, ID mid, int argc, const rb_callable_method_entry_t *cme) { - const struct rb_callcache *cc; + const struct rb_callcache *cc = NULL; RB_VM_LOCK_ENTER(); { @@ -399,10 +399,15 @@ cc_new(VALUE klass, ID mid, int argc, const rb_callable_method_entry_t *cme) rb_id_table_insert(cc_tbl, mid, (VALUE)ccs); } - if (ccs->len > 0) { - cc = ccs->entries[0].cc; + for (int i=0; i<ccs->len; i++) { + cc = ccs->entries[i].cc; + if (vm_cc_cme(cc) == cme) { + break; + } + cc = NULL; } - else { + + if (cc == NULL) { const struct rb_callinfo *ci = vm_ci_new(mid, 0, argc, false); // TODO: proper ci cc = vm_cc_new(klass, cme, vm_call_general); METHOD_ENTRY_CACHED_SET((struct rb_callable_method_entry_struct *)cme); |