By design. GP Script is strongly typed with a little bit of hinting where it makes sense.
Consider what happens if you have
var test : integer
test = 1.5
In the current design, the first value seen in an expression is considered to be the TYPE of the entire expression. Hence, if you write 1 + x, x must be an integer type because 1 is.
A single number without decimal point is of type integer. Numbers with decimal points in them are not integer Numbers just like the string “1” is completely different from the integer number 1 which is completely different than the floating point number 1.0
I have added some automatic type casting for convenience where it makes sense (which is why you can add an integer to a double) but generally you have to use functions to convert from one type to another.
Thanks for the explanation… now that i know what’s behind it, it absolutely makes sense.
But if you don’t know about it, then this is quite strange when you stumble upon it.
Depends what you’re used to. Some languages have weak or no type checking and will just convert from one for another on the fly. But stronger type checking eliminates certain kinds of bugs and is worth the occasional extra work you have to do.