@@ -774,6 +774,52 @@ def test = [target(f: 6), target(10, 20, 30, f: 6), target(10, 20, 30, 40, 50, f
774774 } , call_threshold : 2
775775 end
776776
777+ def test_send_kwarg_partial_optional
778+ assert_compiles '[[1, 2, 3], [1, 20, 3], [10, 2, 30]]' , %q{
779+ def test(a: 1, b: 2, c: 3) = [a, b, c]
780+ def entry = [test, test(b: 20), test(c: 30, a: 10)]
781+ entry
782+ entry
783+ } , call_threshold : 2
784+ end
785+
786+ def test_send_kwarg_optional_a_lot
787+ assert_compiles '[[1, 2, 3, 4, 5, 6], [1, 2, 3, 7, 8, 9], [2, 4, 6, 8, 10, 12]]' , %q{
788+ def test(a: 1, b: 2, c: 3, d: 4, e: 5, f: 6) = [a, b, c, d, e, f]
789+ def entry = [test, test(d: 7, f: 9, e: 8), test(f: 12, e: 10, d: 8, c: 6, b: 4, a: 2)]
790+ entry
791+ entry
792+ } , call_threshold : 2
793+ end
794+
795+ def test_send_kwarg_non_constant_default
796+ assert_compiles '[[1, 2], [10, 2]]' , %q{
797+ def make_default = 2
798+ def test(a: 1, b: make_default) = [a, b]
799+ def entry = [test, test(a: 10)]
800+ entry
801+ entry
802+ } , call_threshold : 2
803+ end
804+
805+ def test_send_kwarg_optional_static_with_side_exit
806+ # verify frame reconstruction with synthesized keyword defaults is correct
807+ assert_compiles '[10, 2, 10]' , %q{
808+ def callee(a: 1, b: 2)
809+ # use binding to force side-exit
810+ x = binding.local_variable_get(:a)
811+ [a, b, x]
812+ end
813+
814+ def entry
815+ callee(a: 10) # b should get default value
816+ end
817+
818+ entry
819+ entry
820+ } , call_threshold : 2
821+ end
822+
777823 def test_send_all_arg_types
778824 assert_compiles '[:req, :opt, :post, :kwr, :kwo, true]' , %q{
779825 def test(a, b = :opt, c, d:, e: :kwo) = [a, b, c, d, e, block_given?]
@@ -1329,6 +1375,23 @@ def test
13291375 } , call_threshold : 2
13301376 end
13311377
1378+ def test_invokesuper_with_optional_keyword_args
1379+ assert_compiles '[1, 2, 3]' , %q{
1380+ class Parent
1381+ def foo(a, b: 2, c: 3) = [a, b, c]
1382+ end
1383+
1384+ class Child < Parent
1385+ def foo(a) = super(a)
1386+ end
1387+
1388+ def test = Child.new.foo(1)
1389+
1390+ test
1391+ test
1392+ } , call_threshold : 2
1393+ end
1394+
13321395 def test_invokebuiltin
13331396 # Not using assert_compiles due to register spill
13341397 assert_runs '["."]' , %q{
0 commit comments