Skip to content

Commit a9e536c

Browse files
msimacekqunaibit
authored andcommitted
Fix incorrect boolean specialization of __abs__
1 parent 68c4b58 commit a9e536c

File tree

1 file changed

+5
-5
lines changed
  • graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ints

1 file changed

+5
-5
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ints/IntBuiltins.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1138,12 +1138,12 @@ private BigInteger op(BigInteger a, long b) {
11381138
@TypeSystemReference(PythonArithmeticTypes.class)
11391139
abstract static class AbsNode extends PythonUnaryBuiltinNode {
11401140
@Specialization
1141-
boolean absBoolean(boolean arg) {
1142-
return arg;
1141+
static int absBoolean(boolean arg) {
1142+
return arg ? 1 : 0;
11431143
}
11441144

11451145
@Specialization(rewriteOn = {ArithmeticException.class, OverflowException.class})
1146-
int absInt(int arg) throws OverflowException {
1146+
static int absInt(int arg) throws OverflowException {
11471147
int result = Math.abs(arg);
11481148
if (result < 0) {
11491149
throw OverflowException.INSTANCE;
@@ -1152,13 +1152,13 @@ int absInt(int arg) throws OverflowException {
11521152
}
11531153

11541154
@Specialization(replaces = "absInt")
1155-
long absIntOvf(int arg) {
1155+
static long absIntOvf(int arg) {
11561156
// Math.abs(Integer#MIN_VALUE) returns Integer#MIN_VALUE
11571157
return Math.abs((long) arg);
11581158
}
11591159

11601160
@Specialization(rewriteOn = {ArithmeticException.class, OverflowException.class})
1161-
long absLong(long arg) throws OverflowException {
1161+
static long absLong(long arg) throws OverflowException {
11621162
long result = Math.abs(arg);
11631163
if (result < 0) {
11641164
throw OverflowException.INSTANCE;

0 commit comments

Comments
 (0)