summaryrefslogtreecommitdiff
path: root/bootstraptest
diff options
context:
space:
mode:
authorAdam Hess <HParker@github.com>2021-11-19 13:57:09 -0800
committerGitHub <noreply@github.com>2021-11-19 16:57:09 -0500
commit73388aff5e2a6c6f5520d4ccc7843990fb15520e (patch)
tree47ceb4156b0781b35d9846cf0b46d1fce07d1d7f /bootstraptest
parent3c92516519bf0cf3ed586462f947ed8c4ed64abd (diff)
Add YJIT codegen for objtostring (#5149)
This is the minimal correct objtostring implementation in YJIT. For correctness, it is important that to_string not get called on strings or subclasses of string. There is a new test for this behavior. A follow up should implement an optimized version for other types as performed in `vm_objtostring`. Co-authored-by: John Hawthorn <jhawthorn@github.com> Co-authored-by: John Hawthorn <jhawthorn@github.com>
Notes
Notes: Merged-By: maximecb <maximecb@ruby-lang.org>
Diffstat (limited to 'bootstraptest')
-rw-r--r--bootstraptest/test_yjit.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/bootstraptest/test_yjit.rb b/bootstraptest/test_yjit.rb
index 33e9a35462..f1900f9f3f 100644
--- a/bootstraptest/test_yjit.rb
+++ b/bootstraptest/test_yjit.rb
@@ -1214,6 +1214,23 @@ assert_equal 'foo123', %q{
make_str("foo", 123)
}
+# test string interpolation with overridden to_s
+assert_equal 'foo', %q{
+ class String
+ def to_s
+ "bad"
+ end
+ end
+
+ def make_str(foo)
+ "#{foo}"
+ end
+
+ make_str("foo")
+ make_str("foo")
+}
+
+
# test invokebuiltin as used in struct assignment
assert_equal '123', %q{
def foo(obj)