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
import sequtils
var b =5typeFoo[T] =object
h, w: intprocbar[T](foos: seq[Foo[T]]) =let w =foldl(foos, a + b.w, 0)
echo w
let foos =@[Foo[int](h: 3, w: 5), Foo[int](h: 4, w: 6)]
bar(foos)
Here I am using foldl, which injects the variables a and b. Apparently, this goes in conflict with the existing variable b. This only happens inside a generic procedure, as above.
The output is
/Users/andrea/playground/nim/example.nim(14, 4) template/generic instantiation of `bar` from here
/Users/andrea/playground/nim/example.nim(9, 28) Error: undeclared field: 'w' for type system.int [declared in /Users/andrea/.mynim/devel/lib/system.nim(26, 3)]
Currently using
Nim Compiler Version 1.0.99 [MacOSX: amd64]
Compiled at 2019-09-27
Copyright (c) 2006-2019 by Andreas Rumpf
git hash: ce4eb4ac916a9b1c7dae42bfb0626a28bbaf5fdf
active boot switches: -d:release
The text was updated successfully, but these errors were encountered:
Easier to explain with an example
Here I am using
foldl
, which injects the variablesa
andb
. Apparently, this goes in conflict with the existing variableb
. This only happens inside a generic procedure, as above.The output is
Currently using
The text was updated successfully, but these errors were encountered: