Thanks for letting me know! Reported the error message (or the behavior) as a
bug <https://github.com/nim-lang/Nim/issues/13683> because I thought it too
hard to get confirmation of what's going on, fingers crossed.
As a followup, is it correct that when there are several generic types, and at
least one of them is the return type, that all types must be specified to the
generic, even if the information would be available to infer both?
type
Foo = object
foo: int
bar: int
Fuz = object
fuz: float
buz: float
proc init[T, U](o: T): U =
discard o
result = U()
# works
let foo = Foo()
let fuz = init[Foo, Fuz](foo)
# fails with "cannot instantiate U" (expected)
# let foo = Foo()
# let fuz:Fuz = init(foo)
# fails with "Error: cannot instantiate: 'init[Fuz]'; got 1 type(s) but
expected 2"
# Can this be made to work with a different syntax?
# let foo = Foo()
# let fuz:Fuz = init[Fuz](foo)
echo foo
echo fuz
Run