summaryrefslogtreecommitdiff
path: root/hash.c
diff options
context:
space:
mode:
authorYusuke Endoh <mame@ruby-lang.org>2019-03-18 14:25:47 +0900
committerJeremy Evans <code@jeremyevans.net>2019-08-30 12:39:31 -0700
commit16c6984bb97409029e213154ac4f633ae04af3d8 (patch)
tree53839e4d596e4016320097530ff5d7fcf19d11e6 /hash.c
parentb0a291f6f6a5834fd84807eb48be906ade429871 (diff)
Separate keyword arguments from positional arguments
And, allow non-symbol keys as a keyword arugment
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/2395
Diffstat (limited to 'hash.c')
-rw-r--r--hash.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/hash.c b/hash.c
index b61784af3a..0f1c460c49 100644
--- a/hash.c
+++ b/hash.c
@@ -30,6 +30,8 @@
# endif
#endif
+VALUE rb_no_keyword_hash;
+
#ifndef HASH_DEBUG
#define HASH_DEBUG 0
#endif
@@ -3274,6 +3276,8 @@ inspect_hash(VALUE hash, VALUE dummy, int recur)
static VALUE
rb_hash_inspect(VALUE hash)
{
+ if (hash == rb_no_keyword_hash)
+ return rb_usascii_str_new2("{(NO KEYWORD)}");
if (RHASH_EMPTY_P(hash))
return rb_usascii_str_new2("{}");
return rb_exec_recursive(inspect_hash, hash, 0);
@@ -6273,6 +6277,10 @@ Init_Hash(void)
*/
rb_define_global_const("ENV", envtbl);
+ rb_no_keyword_hash = rb_hash_new();
+ rb_hash_freeze(rb_no_keyword_hash);
+ rb_gc_register_mark_object(rb_no_keyword_hash);
+
/* for callcc */
ruby_register_rollback_func_for_ensure(hash_foreach_ensure, hash_foreach_ensure_rollback);