Skip to content

Commit f560e40

Browse files
committed
support abs for booleans
1 parent 5955d3a commit f560e40

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinFunctions.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,21 +162,25 @@ public void initialize(PythonCore core) {
162162
// abs(x)
163163
@Builtin(name = ABS, fixedNumOfArguments = 1)
164164
@GenerateNodeFactory
165-
public abstract static class AbsNode extends PythonBuiltinNode {
165+
public abstract static class AbsNode extends PythonUnaryBuiltinNode {
166+
@Specialization
167+
public boolean absInt(boolean arg) {
168+
return arg;
169+
}
166170

167171
@Specialization
168172
public int absInt(int arg) {
169173
return Math.abs(arg);
170174
}
171175

172176
@Specialization
173-
public double absDouble(double arg) {
177+
public long absInt(long arg) {
174178
return Math.abs(arg);
175179
}
176180

177181
@Specialization
178-
public int absBoolean(boolean arg) {
179-
return arg ? 1 : 0;
182+
public double absDouble(double arg) {
183+
return Math.abs(arg);
180184
}
181185

182186
@Specialization

0 commit comments

Comments
 (0)