You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
type X =object
e: intfuncworks(T: type X, v: auto): T =T(e: v)
templatefails(T: type X, v: auto): T =T(e: v)
var
w = X.works(42)
x = X.fails(42)
[arnetheduck@tempus tmp]$ nim c -r testvlang.io
Hint: used config file '/home/arnetheduck/.choosenim/toolchains/nim-0.20.2/config/nim.cfg' [Conf]
Hint: system [Processing]
Hint: widestrs [Processing]
Hint: io [Processing]
Hint: test [Processing]
/home/arnetheduck/tmp/test.nim(9, 8) Error: type expected
[arnetheduck@tempus tmp]$ nim --version
Nim Compiler Version 0.20.2 [Linux: amd64]
Compiled at 2019-07-17
Copyright (c) 2006-2019 by Andreas Rumpf
git hash: 88a0edba4b1a3d535b54336fd589746add54e937
active boot switches: -d:release
The text was updated successfully, but these errors were encountered:
funcworks[T](t: typedesc[T], v: auto): T =T(e: v)
templatefails[T](t: typedesc[T], v: auto): T =T(e: v)
Generally I made good experience to always write out the generic parameter (T) for typedesc parameters and then use this generic parameter instead of the the typedesc value t.
my end goal btw is that this works with generics too (I don't feel that it's terribly valuable to add E to fails explicitly in this case - in particular, I want to forward v to the object init ideally without converting it to E eagerly.
type X[E] =object
e: E
templatefails(T: type X, v: auto): T =T(e: v)
The text was updated successfully, but these errors were encountered: