mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Fix bug in generic case for gen_checktype
When checking for T_HASH, which is Qnil and when the type check succeeds we were outputting to the stack a Qnil instead of a Qtrue.
This commit is contained in:
parent
7d252186fe
commit
da20ff1644
2 changed files with 21 additions and 0 deletions
|
@ -1154,6 +1154,26 @@ assert_equal '7', %q{
|
||||||
foo(5,2)
|
foo(5,2)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# test pattern matching
|
||||||
|
assert_equal '[:ok, :ok]', %q{
|
||||||
|
class C
|
||||||
|
def destructure_keys
|
||||||
|
{}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
pattern_match = ->(i) do
|
||||||
|
case i
|
||||||
|
in a: 0
|
||||||
|
:ng
|
||||||
|
else
|
||||||
|
:ok
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
[{}, C.new].map(&pattern_match)
|
||||||
|
}
|
||||||
|
|
||||||
# Call to object with singleton
|
# Call to object with singleton
|
||||||
assert_equal '123', %q{
|
assert_equal '123', %q{
|
||||||
obj = Object.new
|
obj = Object.new
|
||||||
|
|
|
@ -1421,6 +1421,7 @@ gen_checktype(jitstate_t* jit, ctx_t* ctx)
|
||||||
mov(cb, REG0, mem_opnd(64, REG0, offsetof(struct RBasic, flags)));
|
mov(cb, REG0, mem_opnd(64, REG0, offsetof(struct RBasic, flags)));
|
||||||
and(cb, REG0, imm_opnd(RUBY_T_MASK));
|
and(cb, REG0, imm_opnd(RUBY_T_MASK));
|
||||||
cmp(cb, REG0, imm_opnd(type_val));
|
cmp(cb, REG0, imm_opnd(type_val));
|
||||||
|
mov(cb, REG0, imm_opnd(Qtrue));
|
||||||
mov(cb, REG1, imm_opnd(Qfalse));
|
mov(cb, REG1, imm_opnd(Qfalse));
|
||||||
cmovne(cb, REG0, REG1);
|
cmovne(cb, REG0, REG1);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue