Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions zjit/src/cruby_methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ pub fn init() -> Annotations {
annotate!(rb_cInteger, ">>", inline_integer_rshift);
annotate!(rb_cInteger, "[]", inline_integer_aref);
annotate!(rb_cInteger, "to_s", types::StringExact);
annotate!(rb_cRegexp, "to_s", types::StringExact);
annotate!(rb_cFloat, "+", inline_float_plus);
annotate!(rb_cFloat, "-", inline_float_minus);
annotate!(rb_cFloat, "*", inline_float_mul);
Expand Down
18 changes: 18 additions & 0 deletions zjit/src/hir/opt_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14198,6 +14198,24 @@ mod hir_opt_tests {
");
}

#[test]
fn test_regexp_to_s_returns_string() {
eval(r#"
def test(regexp) = regexp.to_s
test /pattern/
"#);

let hir = hir_string("test");
let regexp_to_s_call = hir
.lines()
.find(|line| line.contains(":Regexp#to_s"))
.expect("expected a Regexp#to_s call in HIR");
assert!(
regexp_to_s_call.contains("StringExact"),
"expected Regexp#to_s to return StringExact, got: {regexp_to_s_call}"
);
}

#[test]
fn test_bignum_to_s_returns_string() {
eval(r#"
Expand Down
Loading