We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 1d3a553 commit d490f28Copy full SHA for d490f28
1 file changed
liquidjava-verifier/src/main/java/liquidjava/rj_language/visitors/CreateASTVisitor.java
@@ -199,10 +199,11 @@ else if (literalContext.STRING() != null)
199
return new LiteralString(literalContext.STRING().getText());
200
else if (literalContext.INT() != null) {
201
String text = literalContext.INT().getText();
202
- try {
203
- return new LiteralInt(text);
204
- } catch (NumberFormatException e) {
205
- return new LiteralLong(text);
+ long value = Long.parseLong(text);
+ if (value <= Integer.MAX_VALUE && value >= Integer.MIN_VALUE) {
+ return new LiteralInt((int) value);
+ } else {
206
+ return new LiteralLong(value);
207
}
208
} else if (literalContext.REAL() != null)
209
return new LiteralReal(literalContext.REAL().getText());
0 commit comments