spec: non-integral constant can be converted to int #11350
Closed
Description
The program is:
package a
const a int = 1-1/1e100
const b int = 1-1/1e300
gotype rejects both assignments.
gc rejects only the first one with "constant 1 truncated to integer", but accepts the second one.
The spec says:
This rounding may cause a floating-point constant expression to be invalid in an integer context, even if it would be integral when calculated using infinite precision.
http://golang.org/ref/spec#Constant_expressions
But it does not say the opposite -- FP const may be valid in int context, even if it is not integral when calculated using infinite precision. I think it should say so.
The second point is that "constant 1 truncated to integer" error does not make sense.