diff --git a/test/ruby/test_proc.rb b/test/ruby/test_proc.rb index 304717e43c..fcf00776a6 100644 --- a/test/ruby/test_proc.rb +++ b/test/ruby/test_proc.rb @@ -377,6 +377,7 @@ class TestProc < Test::Unit::TestCase end def test_dup_clone + # iseq backed proc b = proc {|x| x + "bar" } class << b; attr_accessor :foo; end @@ -389,6 +390,24 @@ class TestProc < Test::Unit::TestCase assert_equal("foobar", bc.call("foo")) bc.foo = :foo assert_equal(:foo, bc.foo) + + # ifunc backed proc + b = {foo: "bar"}.to_proc + + bd = b.dup + assert_equal("bar", bd.call(:foo)) + + bc = b.clone + assert_equal("bar", bc.call(:foo)) + + # symbol backed proc + b = :to_s.to_proc + + bd = b.dup + assert_equal("testing", bd.call(:testing)) + + bc = b.clone + assert_equal("testing", bc.call(:testing)) end def test_dup_subclass diff --git a/vm_core.h b/vm_core.h index 9aa93b7e21..e5169685f1 100644 --- a/vm_core.h +++ b/vm_core.h @@ -1493,7 +1493,7 @@ VM_ENV_ESCAPED_P(const VALUE *ep) static inline int vm_assert_env(VALUE obj) { - VM_ASSERT(imemo_type_p(obj, imemo_env)); + VM_ASSERT(obj == Qundef || imemo_type_p(obj, imemo_env)); return 1; } #endif