Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions src/main/interpreter/Visitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ public MSType visitFuncCall(MineScriptParser.FuncCallContext ctx) {
}

if (actualParams.size() != 1 || !(actualParams.get(0) instanceof MSBool b)) {
throw new RuntimeException(getFuncCallErrorMessage(id, new int[]{1}, "bool", actualParams));
throw new RuntimeException(getFuncCallErrorMessage(id, new int[]{0, 1}, "bool", actualParams));
}

shouldBreak = b.getValue();
Expand Down Expand Up @@ -689,8 +689,18 @@ private MSNumber calculateArithmeticExpression(MSNumber left, MSNumber right, St
case "+" -> leftBig.add(rightBig);
case "-" -> leftBig.subtract(rightBig);
case "*" -> leftBig.multiply(rightBig);
case "/" -> leftBig.divide(rightBig);
case "%" -> leftBig.mod(rightBig);
case "/" -> {
if (rightBig.equals(BigInteger.ZERO)) {
throw new RuntimeException("Cannot divide by 0");
}
yield leftBig.divide(rightBig);
}
case "%" -> {
if (rightBig.compareTo(BigInteger.ZERO) <= 0) {
throw new RuntimeException("Modulus must be positive");
}
yield leftBig.mod(rightBig);
}
case "^" -> leftBig.pow(rightBig.intValue());
default -> throw new RuntimeException("Unknown operator: " + operator);
};
Expand Down