proc foo[T](x: float): T = T(x)
echo foo[int](1.0) #1 compiles
echo 1.0.foo[int]() #2 Error: cannot instantiate: 'T'
proc bar[T](x: float, _: typedesc[T]): T = T(x)
echo bar(1.0, int) #3 compiles
echo 1.0.bar(int) #4 compiles
proc baz[T](x: float, _: T): T = T(x)
echo baz(1.0, 1) #5 compiles
echo 1.0.baz(1) #6 compiles
proc qux(x: float, T: typedesc): T = T(x)
echo qux(1.0, int) #7 triggers ^ Error here: type expected
1. Why `#2` failed to compile while `#4` and `#6` compiles just fine?
2. Why `#7` triggers the `qux` definition failed to compile? Or, why `T` can
be used as return type just fine, but cannot be used as a type in the procedure
body?
I'm using Nim Compiler 0.14.2.