diff --git a/lib/cext/ABI_check.txt b/lib/cext/ABI_check.txt index 0cfbf08886fc..b8626c4cff28 100644 --- a/lib/cext/ABI_check.txt +++ b/lib/cext/ABI_check.txt @@ -1 +1 @@ -2 +4 diff --git a/lib/cext/include/ruby/internal/core/rarray.h b/lib/cext/include/ruby/internal/core/rarray.h index 21e1534731fd..e9b10e714ecc 100644 --- a/lib/cext/include/ruby/internal/core/rarray.h +++ b/lib/cext/include/ruby/internal/core/rarray.h @@ -279,7 +279,7 @@ long rb_array_len(VALUE a); int RARRAY_LENINT(VALUE ary); VALUE *RARRAY_PTR_IMPL(VALUE array); void rb_ary_store(VALUE, long, VALUE); -VALUE RARRAY_AREF(VALUE array, long index); +VALUE rb_tr_rarray_aref(VALUE array, long index); #endif RBIMPL_SYMBOL_EXPORT_END() @@ -611,7 +611,7 @@ RARRAY_ASET(VALUE ary, long i, VALUE v) * transition path, but currently no way is found to do so. */ #ifdef TRUFFLERUBY -#define RARRAY_AREF RARRAY_AREF +#define RARRAY_AREF rb_tr_rarray_aref #else #define RARRAY_AREF(a, i) RARRAY_CONST_PTR_TRANSIENT(a)[i] #endif diff --git a/lib/cext/include/truffleruby/truffleruby.h b/lib/cext/include/truffleruby/truffleruby.h index eb2bcf1a0514..7886bb84bd1b 100644 --- a/lib/cext/include/truffleruby/truffleruby.h +++ b/lib/cext/include/truffleruby/truffleruby.h @@ -278,7 +278,6 @@ static inline int rb_tr_scan_args_kw_int(int kw_flag, int argc, VALUE *argv, str if (parse_data.rest || argc <= n_mand + n_opt) { parse_data.kwargs = false; erased_kwargs = true; - rb_warn("The last argument is nil, treating as empty keywords"); } } else { diff --git a/spec/ruby/library/datetime/rfc2822_spec.rb b/spec/ruby/library/datetime/rfc2822_spec.rb index 70bfca60b4b3..83f7fa8d5b19 100644 --- a/spec/ruby/library/datetime/rfc2822_spec.rb +++ b/spec/ruby/library/datetime/rfc2822_spec.rb @@ -3,4 +3,8 @@ describe "DateTime.rfc2822" do it "needs to be reviewed for spec completeness" + + it "raises DateError if passed nil" do + -> { DateTime.rfc2822(nil) }.should raise_error(Date::Error, "invalid date") + end end diff --git a/spec/ruby/optional/capi/util_spec.rb b/spec/ruby/optional/capi/util_spec.rb index 320527521bbe..2c16999cdc35 100644 --- a/spec/ruby/optional/capi/util_spec.rb +++ b/spec/ruby/optional/capi/util_spec.rb @@ -127,6 +127,19 @@ ScratchPad.recorded.should == [1, 7, 4] end + it "assigns optional arguments with no hash argument given" do + @o.rb_scan_args([1, 7], "02:", 3, @acc).should == 2 + ScratchPad.recorded.should == [1, 7, nil] + end + + it "assigns optional arguments with no hash argument given and rejects the use of optional nil argument as a hash" do + -> { + @o.rb_scan_args([1, nil], "02:", 3, @acc).should == 2 + }.should_not complain + + ScratchPad.recorded.should == [1, nil, nil] + end + it "assigns required, optional, splat, post-splat, Hash and block arguments" do h = {a: 1, b: 2} @o.rb_scan_args([1, 2, 3, 4, 5, h], "k11*1:&", 6, @acc, &@prc).should == 5 diff --git a/src/main/c/cext/array.c b/src/main/c/cext/array.c index b5ae3ece1af6..aad8c8c1589e 100644 --- a/src/main/c/cext/array.c +++ b/src/main/c/cext/array.c @@ -20,7 +20,7 @@ int RARRAY_LENINT(VALUE array) { return polyglot_get_array_size(rb_tr_unwrap(array)); } -VALUE RARRAY_AREF(VALUE array, long index) { +VALUE rb_tr_rarray_aref(VALUE array, long index) { return rb_tr_wrap(polyglot_get_array_element(rb_tr_unwrap(array), (int) index)); }