A similar case to #9214 but more broken:
#!/usr/bin/env ruby
MyData = Struct.new(:value)
# Test 3: FAILS - Data.define with BOTH *args and **kwargs
def test_data_with_both_splats(*args, **kwargs)
MyData.new(*args, **kwargs)
end
begin
puts "✓ Test 3 - Data.define with both splats: #{test_data_with_both_splats("ok").value}"
rescue ArgumentError => e
puts "✗ Test 3 - Data.define with both splats: #{e.class}: #{e.message}"
end
This produces a ClassCastException when it improperly handles the string being passed in lieu of keyword arguments.
$ jruby blah.rb
Unhandled Java exception: java.lang.ClassCastException: class org.jruby.RubyString cannot be cast to class org.jruby.RubyHash (org.jruby.RubyString and org.jruby.RubyHash are in module org.jruby.dist of loader 'app')
java.lang.ClassCastException: class org.jruby.RubyString cannot be cast to class org.jruby.RubyHash (org.jruby.RubyString and org.jruby.RubyHash are in module org.jruby.dist of loader 'app')
initialize at org/jruby/RubyStruct.java:537
call at org/jruby/RubyStruct$INVOKER$i$initialize.gen:-1
call at org/jruby/internal/runtime/methods/JavaMethod.java:841
cacheAndCall at org/jruby/runtime/callsite/CachingCallSite.java:446
call at org/jruby/runtime/callsite/CachingCallSite.java:92
callInit at org/jruby/RubyObject.java:274
newStruct at org/jruby/api/Create.java:487
newStruct at org/jruby/RubyStruct.java:339
call at org/jruby/RubyStruct$StructMethods$INVOKER$s$newStruct.gen:-1
performIndirectCall at org/jruby/ir/targets/indy/InvokeSite.java:882
invoke at org/jruby/ir/targets/indy/InvokeSite.java:786
️❤ def test_data_with_both_splats #0 at blah.rb:7
Reactions are currently unavailable
A similar case to #9214 but more broken:
#!/usr/bin/env ruby MyData = Struct.new(:value) # Test 3: FAILS - Data.define with BOTH *args and **kwargs def test_data_with_both_splats(*args, **kwargs) MyData.new(*args, **kwargs) end begin puts "✓ Test 3 - Data.define with both splats: #{test_data_with_both_splats("ok").value}" rescue ArgumentError => e puts "✗ Test 3 - Data.define with both splats: #{e.class}: #{e.message}" endThis produces a ClassCastException when it improperly handles the string being passed in lieu of keyword arguments.
$ jruby blah.rb Unhandled Java exception: java.lang.ClassCastException: class org.jruby.RubyString cannot be cast to class org.jruby.RubyHash (org.jruby.RubyString and org.jruby.RubyHash are in module org.jruby.dist of loader 'app') java.lang.ClassCastException: class org.jruby.RubyString cannot be cast to class org.jruby.RubyHash (org.jruby.RubyString and org.jruby.RubyHash are in module org.jruby.dist of loader 'app') initialize at org/jruby/RubyStruct.java:537 call at org/jruby/RubyStruct$INVOKER$i$initialize.gen:-1 call at org/jruby/internal/runtime/methods/JavaMethod.java:841 cacheAndCall at org/jruby/runtime/callsite/CachingCallSite.java:446 call at org/jruby/runtime/callsite/CachingCallSite.java:92 callInit at org/jruby/RubyObject.java:274 newStruct at org/jruby/api/Create.java:487 newStruct at org/jruby/RubyStruct.java:339 call at org/jruby/RubyStruct$StructMethods$INVOKER$s$newStruct.gen:-1 performIndirectCall at org/jruby/ir/targets/indy/InvokeSite.java:882 invoke at org/jruby/ir/targets/indy/InvokeSite.java:786 ️❤ def test_data_with_both_splats #0 at blah.rb:7