Skip to content

Commit d490f28

Browse files
change catch to if max values
1 parent 1d3a553 commit d490f28

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

liquidjava-verifier/src/main/java/liquidjava/rj_language/visitors/CreateASTVisitor.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -199,10 +199,11 @@ else if (literalContext.STRING() != null)
199199
return new LiteralString(literalContext.STRING().getText());
200200
else if (literalContext.INT() != null) {
201201
String text = literalContext.INT().getText();
202-
try {
203-
return new LiteralInt(text);
204-
} catch (NumberFormatException e) {
205-
return new LiteralLong(text);
202+
long value = Long.parseLong(text);
203+
if (value <= Integer.MAX_VALUE && value >= Integer.MIN_VALUE) {
204+
return new LiteralInt((int) value);
205+
} else {
206+
return new LiteralLong(value);
206207
}
207208
} else if (literalContext.REAL() != null)
208209
return new LiteralReal(literalContext.REAL().getText());

0 commit comments

Comments
 (0)