From cf71e5f62a28eda22d67e3b4bad30fdff766fedc Mon Sep 17 00:00:00 2001 From: Maxime Chevalier-Boisvert Date: Tue, 3 May 2022 13:44:43 -0400 Subject: [PATCH] Add a regression test for opt_plus with unknown type (#5878) --- test/ruby/test_yjit.rb | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/test/ruby/test_yjit.rb b/test/ruby/test_yjit.rb index 9ad59bc962..88be6622ce 100644 --- a/test/ruby/test_yjit.rb +++ b/test/ruby/test_yjit.rb @@ -1,4 +1,8 @@ # frozen_string_literal: true +# +# This set of tests can be run with: +# make test-all TESTS='test/ruby/test_yjit.rb' RUN_OPTS="--yjit-call-threshold=1" + require 'test/unit' require 'envutil' require 'tmpdir' @@ -453,6 +457,27 @@ class TestYJIT < Test::Unit::TestCase RUBY end + def test_getivar_opt_plus + assert_no_exits(<<~RUBY) + class TheClass + def initialize + @levar = 1 + end + + def get_sum + sum = 0 + # The type of levar is unknown, + # but this still should not exit + sum += @levar + sum + end + end + + obj = TheClass.new + obj.get_sum + RUBY + end + def test_super_iseq assert_compiles(<<~'RUBY', insns: %i[invokesuper opt_plus opt_mult], result: 15) class A