Nim/tests/generics/tforwardgeneric.nim
Arne Döring b2c6db97f9
printing float values will have one more digit. (#13276) [backport]
* printing float values will have one more digit. Fixes #13196
2020-02-07 17:10:25 +01:00

27 lines
642 B
Nim

discard """
output: "1.125 11\n42\n0"
ccodecheck: "!@'ClEnv'"
"""
proc p[T](a, b: T): T
echo p(0.875, 0.125), " ", p(9, 1)
proc p[T](a, b: T): T =
let c = b
result = a + b + c
# https://github.com/nim-lang/Nim/issues/4908
proc foo(t: typedesc[int]): int
proc bar(): int = foo(int)
proc foo(t: typedesc[int]): int =
return 0
# https://github.com/nim-lang/Nim/issues/4104
proc print[T](t: T) # Error: implementation of 'print.print(t: int)' expected
print 42 # moving this line after the implementation fixes the error,
# but such behaviour makes forward declaration pointless
proc print[T](t: T) =
echo t
echo bar()