From 73388aff5e2a6c6f5520d4ccc7843990fb15520e Mon Sep 17 00:00:00 2001 From: Adam Hess Date: Fri, 19 Nov 2021 13:57:09 -0800 Subject: 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 Co-authored-by: John Hawthorn --- bootstraptest/test_yjit.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'bootstraptest') 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) -- cgit v1.2.3