Skip to content

Commit 8dda029

Browse files
committed
Add defensive code.
1 parent 865c17d commit 8dda029

File tree

1 file changed

+3
-2
lines changed
  • com.ibm.wala.cast.python.ml/source/com/ibm/wala/cast/python/ml/client

1 file changed

+3
-2
lines changed

com.ibm.wala.cast.python.ml/source/com/ibm/wala/cast/python/ml/client/Range.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ protected Set<List<Dimension<?>>> getShapes(PropagationCallGraphBuilder builder)
8686
int shape = (int) Math.ceil((limit - start) / delta);
8787
ret.add(List.of(new NumericDim(shape))); // Add the shape as a 1D tensor.
8888
}
89-
} else if (numOfPoisitionArguments == 3) {
89+
} else if (numOfPoisitionArguments >= 3) {
9090
// it must be `start`, `limit`, and `delta`.
9191
int startValueNumber =
9292
this.getNode().getMethod().isStatic()
@@ -136,7 +136,7 @@ protected Set<List<Dimension<?>>> getShapes(PropagationCallGraphBuilder builder)
136136
}
137137
} else
138138
throw new IllegalStateException(
139-
"Expected either 1 or 3 positional arguments for range(), but got: "
139+
"Expected either 1 or >= 3 positional arguments for range(), but got: "
140140
+ numOfPoisitionArguments
141141
+ ".");
142142

@@ -195,6 +195,7 @@ protected EnumSet<DType> getDefaultDTypes(PropagationCallGraphBuilder builder) {
195195
.map(
196196
numArgs ->
197197
IntStream.range(0, numArgs)
198+
.filter(i -> i < 3) // only numeric arguments.
198199
.map(i -> this.getNode().getIR().getMethod().isStatic() ? i : i + 1)
199200
.map(this.getNode().getIR()::getParameter)
200201
.mapToObj(val -> getDTypes(builder, val).stream())

0 commit comments

Comments
 (0)