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
Naming a static object parameter the same as one of their fields produces a type mismatch when it's passed to a macro. Removing the macro make it work as expected. I found this while trying to make a snippet for #13252
Example
import macros
typeFooBar=object
a: seq[int]
macrogenFoobar(a: staticFooBar): untyped=result=newStmtList()
for b in a.a:
result.add(newCall(bindSym"echo", newLit b))
procfoobar(a: staticFooBar) =genFoobar(a) # removing this make it workfor b in a.a:
echo"foo"&$b
procmain() =const a: seq[int] =@[1, 2,3]
# Error: type mismatch: got <array[0..2, int]> but expected 'seq[int]'const fb =Foobar(a: a)
foobar(fb)
main()
Current Output
Error: type mismatch: got <array[0..2, int]> but expected 'seq[int]'
Expected Output
1
2
3
foo1
foo2
foo3
Additional Information
Tried in Nim devel and 1.0.4
$ nim -v
Nim Compiler Version 1.1.1 [Linux: amd64]
Compiled at 2020-01-24
Copyright (c) 2006-2019 by Andreas Rumpf
active boot switches: -d:release
The text was updated successfully, but these errors were encountered:
Naming a static object parameter the same as one of their fields produces a type mismatch when it's passed to a macro. Removing the macro make it work as expected. I found this while trying to make a snippet for #13252
Example
Current Output
Expected Output
Additional Information
The text was updated successfully, but these errors were encountered: