Skip to content

Commit 914a1f4

Browse files
committed
Fix: do not allow array mult if object is a also a number.
1 parent d3516df commit 914a1f4

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/foreign/TruffleObjectBuiltins.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ abstract static class MulNode extends ForeignBinaryNode {
311311
super(BinaryArithmetic.Mul.create(), false);
312312
}
313313

314-
@Specialization(insertBefore = "doComparisonBool", guards = {"lib.hasArrayElements(left)", "lib.fitsInInt(right)"})
314+
@Specialization(insertBefore = "doComparisonBool", guards = {"!lib.isNumber(left)", "lib.hasArrayElements(left)", "lib.fitsInInt(right)"})
315315
static Object doForeignArray(Object left, Object right,
316316
@Cached PRaiseNode raise,
317317
@Cached PythonObjectFactory factory,
@@ -341,7 +341,7 @@ static Object doForeignArray(Object left, Object right,
341341
}
342342
}
343343

344-
@Specialization(insertBefore = "doComparisonBool", guards = {"lib.hasArrayElements(left)", "lib.isBoolean(right)"})
344+
@Specialization(insertBefore = "doComparisonBool", guards = {"!lib.isNumber(left)", "lib.hasArrayElements(left)", "lib.isBoolean(right)"})
345345
static Object doForeignArrayForeignBoolean(Object left, Object right,
346346
@Cached PRaiseNode raise,
347347
@Cached PythonObjectFactory factory,
@@ -355,7 +355,7 @@ static Object doForeignArrayForeignBoolean(Object left, Object right,
355355
}
356356

357357
@SuppressWarnings("unused")
358-
@Specialization(insertBefore = "doGeneric", guards = {"lib.hasArrayElements(left)", "isNegativeNumber(lib, right)"})
358+
@Specialization(insertBefore = "doGeneric", guards = {"!lib.isNumber(left)", "lib.hasArrayElements(left)", "isNegativeNumber(lib, right)"})
359359
static Object doForeignArrayNegativeMult(Object left, Object right,
360360
@Cached PythonObjectFactory factory,
361361
@CachedLibrary(limit = "3") InteropLibrary lib) {

0 commit comments

Comments
 (0)