I wonder whether integers work in Nim as most people would expect.

Is anybody surprised by the output of the program below?
    
    
    const c_1bn = 1_000_000_000
    
    let i_4bn = 4 * c_1bn
    
    proc test_1[T](n : T) = echo n, "A"
    
    proc test_1[T : int|uint](n : T) = echo n, "B"
    
    proc test_1(n : int64) = echo n, "C"
    
    proc test_1(n : int16) = echo n, "D"
    
    test_1(c_1bn)
    test_1(2'i8)
    test_1(3'u16)
    test_1(i_4bn)
    
    
    proc test_2[T](n : T) = echo n, "A"
    
    proc test_2[T : int](n : T) = echo n, "B"
    
    proc test_2(n : uint) = echo n, "C"
    
    proc test_2(n : int16) = echo n, "D"
    
    test_2(5_000_000_000)
    test_2(6'i8)
    test_2(7'u16)
    
    
    proc test_3[T](n : T) = echo n, "A"
    
    proc test_3[T : uint](n : T) = echo n, "B"
    
    proc test_3(n : int) = echo n, "C"
    
    proc test_3(n : int64) = echo n, "D"
    
    test_3(8_000_000_000)
    test_3(9'i8)
    test_3(10'u16)
    
    
    Run

(Wrong answers: 1abcd2bcd3bcd4abcd5bcd6bcd7bcd8abc9bcd10bcd)

Reply via email to