mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-07 04:23:41 +00:00
compiler: fix non-int integer constants
Before this change, the compiler could panic with the following message:
panic: 20 not an Int
That of course doesn't make much sense. But it apparently is expected
behavior, see https://github.com/golang/go/issues/43165 for details.
This commit fixes this issue by converting the constant to an integer if
needed.
This commit is contained in:
committed by
Ron Evans
parent
5917b8baa2
commit
fb0bb69f62
Vendored
+5
@@ -70,6 +70,11 @@ func main() {
|
||||
println(ashrNeg == -1)
|
||||
println(ashrOverflow == 0)
|
||||
println(ashrNegOverflow == -1)
|
||||
|
||||
// fix for a bug in constant numbers
|
||||
println("constant number")
|
||||
x := uint32(5)
|
||||
println(uint32(x) / (20e0 / 1))
|
||||
}
|
||||
|
||||
var x = true
|
||||
|
||||
Reference in New Issue
Block a user