From 0e530dbb63b9755770cbbf4c26bf9de4d4c90fd9 Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Mon, 18 Jul 2022 08:29:52 +0900 Subject: [PATCH] numeric.c: fix `smallint op bigint` error in bitwise logical operators. --- src/numeric.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/numeric.c b/src/numeric.c index 2365d7bbd..239492add 100644 --- a/src/numeric.c +++ b/src/numeric.c @@ -1382,6 +1382,9 @@ int_and(mrb_state *mrb, mrb_value x) if (mrb_bigint_p(x)) { return mrb_bint_and(mrb, x, y); } + if (mrb_bigint_p(y)) { + return mrb_bint_and(mrb, mrb_as_bint(mrb, x), y); + } #endif bit_op(x, y, and, &); } @@ -1403,6 +1406,9 @@ int_or(mrb_state *mrb, mrb_value x) if (mrb_bigint_p(x)) { return mrb_bint_or(mrb, x, y); } + if (mrb_bigint_p(y)) { + return mrb_bint_or(mrb, mrb_as_bint(mrb, x), y); + } #endif bit_op(x, y, or, |); } @@ -1424,6 +1430,9 @@ int_xor(mrb_state *mrb, mrb_value x) if (mrb_bigint_p(x)) { return mrb_bint_xor(mrb, x, y); } + if (mrb_bigint_p(y)) { + return mrb_bint_xor(mrb, mrb_as_bint(mrb, x), y); + } #endif bit_op(x, y, or, ^); }