summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--class.c2
-rw-r--r--test/ruby/test_io.rb3
2 files changed, 4 insertions, 1 deletions
diff --git a/class.c b/class.c
index de837c6aa4..3c08ea4fab 100644
--- a/class.c
+++ b/class.c
@@ -1788,7 +1788,7 @@ rb_scan_args(int argc, const VALUE *argv, const char *fmt, ...)
if (!NIL_P(hash)) {
VALUE opts = rb_extract_keywords(&hash);
if (!hash) argc--;
- hash = opts;
+ hash = opts ? opts : Qnil;
}
}
}
diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb
index 4dc7599b99..8eb94e367a 100644
--- a/test/ruby/test_io.rb
+++ b/test/ruby/test_io.rb
@@ -2981,6 +2981,9 @@ End
File.unlink(path)
IO.write(path, "foo", encoding: Encoding::UTF_32BE)
assert_equal("\0\0\0f\0\0\0o\0\0\0o", File.binread(path))
+ assert_raise(TypeError) {
+ IO.write(path, "foo", Object.new => Object.new)
+ }
ensure
t.close!
end