blob: 87991071c526d1720f071167b4d432c3686dba7b (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
discard """
targets: "c cpp js"
"""
template main() =
block: # bug #8404
# can conv
template float2int(T) =
var a = -1.0
let b = T(a)
doAssert b < 0
let c = b + 1
doAssert c is T
doAssert c == 0
float2int(int8)
float2int(int16)
float2int(int32)
float2int(int64)
block:
# can handle middle conv
# `/` can trigger int to float
template float2int(T) =
let n = T(1 / 256)
doAssert n == 0
float2int(int8)
float2int(int16)
float2int(int32)
# float2int(int64)
main()
static:
main()
|