summaryrefslogtreecommitdiff
path: root/object.c
diff options
context:
space:
mode:
authorJeremy Evans <code@jeremyevans.net>2019-09-18 12:08:14 -0700
committerJeremy Evans <code@jeremyevans.net>2019-09-20 07:45:11 -0700
commit27b67468724dc48ed8305d8cb33484a4af98fc05 (patch)
treeed3a664dc2f2a7f729894a3d253171ce19b7f25b /object.c
parente81a3e6df54842b5a836dad7055a4295cf4155bc (diff)
Make passing empty keywords to dig pass empty keywords to next dig method
If defined in Ruby, dig would be defined as def dig(arg, *rest) end, it would not use keywords. If the last dig argument was an empty hash, it could be treated as keyword arguments by the next dig method. Allow dig to pass along the empty keyword flag if called with an empty keyword, to suppress the previous behavior and force treating the hash as a positional argument and not keywords. Also handle the case where dig calls method_missing, passing the empty keyword flag to that as well. This requires adding rb_check_funcall_with_hook_kw functions, so that dig can specify how arguments are treated. It also adds kw_splat arguments to a couple static functions.
Diffstat (limited to 'object.c')
-rw-r--r--object.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/object.c b/object.c
index de2d72fae3..9c603a8f10 100644
--- a/object.c
+++ b/object.c
@@ -4071,8 +4071,11 @@ rb_obj_dig(int argc, VALUE *argv, VALUE obj, VALUE notfound)
break;
}
}
- return rb_check_funcall_with_hook(obj, id_dig, argc, argv,
- no_dig_method, obj);
+ return rb_check_funcall_with_hook_kw(obj, id_dig, argc, argv,
+ no_dig_method, obj,
+ rb_empty_keyword_given_p() ?
+ RB_PASS_EMPTY_KEYWORDS :
+ RB_NO_KEYWORDS);
}
return obj;
}