Unverified Commit 40d0d8fe authored by KOBAYASHI Shuji's avatar KOBAYASHI Shuji Committed by Yukihiro "Matz" Matsumoto

Fix `Fixnum` and `Float` comparison in `Hash` lookup

  ```console
  $ bin/mruby -e 'p({1 => 2}.key?(1.0))'
  true
  ```

  ```console
  $ bin/mruby -e 'p({1 => 2}.key?(1.0))'
  false
  ```
parent ee544dc8
......@@ -96,27 +96,13 @@ ht_hash_equal(mrb_state *mrb, htable *t, mrb_value a, mrb_value b)
return mrb_symbol(a) == mrb_symbol(b);
case MRB_TT_FIXNUM:
switch (mrb_type(b)) {
case MRB_TT_FIXNUM:
if (!mrb_fixnum_p(b)) return FALSE;
return mrb_fixnum(a) == mrb_fixnum(b);
#ifndef MRB_NO_FLOAT
case MRB_TT_FLOAT:
return (mrb_float)mrb_fixnum(a) == mrb_float(b);
#endif
default:
return FALSE;
}
#ifndef MRB_NO_FLOAT
case MRB_TT_FLOAT:
switch (mrb_type(b)) {
case MRB_TT_FIXNUM:
return mrb_float(a) == (mrb_float)mrb_fixnum(b);
case MRB_TT_FLOAT:
if (!mrb_float_p(b)) return FALSE;
return mrb_float(a) == mrb_float(b);
default:
return FALSE;
}
#endif
default:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment