Skip to content

Commit 88d046e

Browse files
committed
ZJIT: Add HIR tests for hash as positional arg to keyword-only method
Follow-up to rubyGH-16223 to also cover this at the HIR level.
1 parent ac57159 commit 88d046e

1 file changed

Lines changed: 54 additions & 0 deletions

File tree

zjit/src/hir/opt_tests.rs

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3810,6 +3810,60 @@ mod hir_opt_tests {
38103810
");
38113811
}
38123812

3813+
#[test]
3814+
fn test_send_hash_to_kwarg_only_method() {
3815+
eval(r#"
3816+
def callee(a:) = a
3817+
def test = callee({a: 1})
3818+
begin; test; rescue ArgumentError; end
3819+
begin; test; rescue ArgumentError; end
3820+
"#);
3821+
assert_snapshot!(hir_string("test"), @r"
3822+
fn test@<compiled>:3:
3823+
bb1():
3824+
EntryPoint interpreter
3825+
v1:BasicObject = LoadSelf
3826+
Jump bb3(v1)
3827+
bb2():
3828+
EntryPoint JIT(0)
3829+
v4:BasicObject = LoadArg :self@0
3830+
Jump bb3(v4)
3831+
bb3(v6:BasicObject):
3832+
v11:HashExact[VALUE(0x1000)] = Const Value(VALUE(0x1000))
3833+
v12:HashExact = HashDup v11
3834+
v14:BasicObject = Send v6, :callee, v12 # SendFallbackReason: Argument count does not match parameter count
3835+
CheckInterrupts
3836+
Return v14
3837+
");
3838+
}
3839+
3840+
#[test]
3841+
fn test_send_hash_to_optional_kwarg_only_method() {
3842+
eval(r#"
3843+
def callee(a: nil) = a
3844+
def test = callee({a: 1})
3845+
begin; test; rescue ArgumentError; end
3846+
begin; test; rescue ArgumentError; end
3847+
"#);
3848+
assert_snapshot!(hir_string("test"), @r"
3849+
fn test@<compiled>:3:
3850+
bb1():
3851+
EntryPoint interpreter
3852+
v1:BasicObject = LoadSelf
3853+
Jump bb3(v1)
3854+
bb2():
3855+
EntryPoint JIT(0)
3856+
v4:BasicObject = LoadArg :self@0
3857+
Jump bb3(v4)
3858+
bb3(v6:BasicObject):
3859+
v11:HashExact[VALUE(0x1000)] = Const Value(VALUE(0x1000))
3860+
v12:HashExact = HashDup v11
3861+
v14:BasicObject = Send v6, :callee, v12 # SendFallbackReason: Argument count does not match parameter count
3862+
CheckInterrupts
3863+
Return v14
3864+
");
3865+
}
3866+
38133867
#[test]
38143868
fn specialize_call_to_iseq_with_optional_param_kw_using_default() {
38153869
eval("

0 commit comments

Comments
 (0)