Can't use interger literal -9223372036854775808
Seems like the parser can't parse integer literals greater than 9223372036854775807
echo 'type int64 = -9223372036854775808..9223372036854775807' | minizinc -
stdin:1.15-33:
type int64 = -9223372036854775808..9223372036854775807
^^^^^^^^^^^^^^^^^^^
Error: syntax error, unexpected invalid integer literal
Internally, -9223372036854775808 seems to be fine:
int: a = -9223372036854775807 - 1;
int: b = 9223372036854775807;
output ["\(a) \(b)"];
The backend solvers have their own integer limits.
This is due to a quirk in the way integer literals and the - operator are parsed. Like in other languages, -9223372036854775808 is parsed as the negation operator - followed by the integer literal 9223372036854775808. Since the literal is outside of the range of valid integers, you get the invalid integer literal error. This is not easy to fix in the current architecture, since it would require changing the internal representation of integers used in the parser. The only workaround is to calculate the value (like in @a1880's comment):
type int64 = -9223372036854775807-1..9223372036854775807;
We should probably add suitably defined constants to the library.
This is due to a quirk in the way integer literals and the
-operator are parsed. Like in other languages,-9223372036854775808is parsed as the negation operator-followed by the integer literal9223372036854775808. Since the literal is outside of the range of valid integers, you get theinvalid integer literalerror. This is not easy to fix in the current architecture, since it would require changing the internal representation of integers used in the parser. The only workaround is to calculate the value (like in @a1880's comment):type int64 = -9223372036854775807-1..9223372036854775807;We should probably add suitably defined constants to the library.
I suspected as much, FWIW this is not something I need or rely on, I came across this by accident and I think the workaround is fine in case I ever need it
Turns out the fix wasn't too difficult after all (although it's a bit ugly).