Skip to content

Commit d28151f

Browse files
committed
Check that splitIndex is not negative
1 parent 51d8ad0 commit d28151f

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

packages/cashc/src/semantic/TypeCheckTraversal.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,10 @@ function inferTupleType(node: BinaryOpNode): Type {
406406
return new TupleType(new BytesType(splitIndex), new BytesType());
407407
}
408408

409+
if (splitIndex < 0) {
410+
throw new IndexOutOfBoundsError(node);
411+
}
412+
409413
if (splitIndex > expressionType.bound) {
410414
throw new IndexOutOfBoundsError(node);
411415
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
contract Test(bytes8 b) {
2+
function spend() {
3+
bytes x = b.split(-4)[0];
4+
require(x != b);
5+
}
6+
}

0 commit comments

Comments
 (0)