Fix assertion when envval of proc is Qundef
The following code crashes with assertions enabled because envval could be Qundef: {}.to_proc.dup
This commit is contained in:
parent
4bcfff07ab
commit
843b4f49ee
Notes:
git
2024-10-31 17:52:46 +00:00
@ -377,6 +377,7 @@ class TestProc < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_dup_clone
|
def test_dup_clone
|
||||||
|
# iseq backed proc
|
||||||
b = proc {|x| x + "bar" }
|
b = proc {|x| x + "bar" }
|
||||||
class << b; attr_accessor :foo; end
|
class << b; attr_accessor :foo; end
|
||||||
|
|
||||||
@ -389,6 +390,24 @@ class TestProc < Test::Unit::TestCase
|
|||||||
assert_equal("foobar", bc.call("foo"))
|
assert_equal("foobar", bc.call("foo"))
|
||||||
bc.foo = :foo
|
bc.foo = :foo
|
||||||
assert_equal(:foo, bc.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
|
end
|
||||||
|
|
||||||
def test_dup_subclass
|
def test_dup_subclass
|
||||||
|
@ -1493,7 +1493,7 @@ VM_ENV_ESCAPED_P(const VALUE *ep)
|
|||||||
static inline int
|
static inline int
|
||||||
vm_assert_env(VALUE obj)
|
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;
|
return 1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user