Closed
Description
tuples give codegen error
Example
const a = $("a", "b")
proc fun() =
const str = $int # ditto with import std/typetraits and `const str = name(T)` for a type T,
let b = $(str, "asdf")
fun()
Current Output
nim cpp main.nim
@mt0792.nim.c:100:39: error: passing 'const tyTuple__ZQxPyw7zPWZWYS61MfQJzw' (aka 'const struct tyTuple__ZQxPyw7zPWZWYS61MfQJzw') to parameter of incompatible type 'tyTuple__UV3llMMYFckfui8YMBuUZA' (aka 'struct tyTuple__UV3llMMYFckfui8YMBuUZA')
b = dollar___QX30i9a0JRHUXu5QkLQcZiA(TM__lALVhCR9bMfGqd1f9ckszw0A_2);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/tmp/d04/@mt0792.nim.c:54:107: note: passing argument to parameter 'x' here
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, dollar___QX30i9a0JRHUXu5QkLQcZiA)(tyTuple__UV3llMMYFckfui8YMBuUZA x);
nim c main.nim
@mt0792.nim.cpp:99:6: error: no matching function for call to 'dollar___QX30i9a0JRHUXu5QkLQcZiA'
b = dollar___QX30i9a0JRHUXu5QkLQcZiA(TM__lALVhCR9bMfGqd1f9ckszw0A_2);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/tmp/d04/@mt0792.nim.cpp:53:41: note: candidate function not viable: no known conversion from 'tyTuple__ZQxPyw7zPWZWYS61MfQJzw' to 'tyTuple__UV3llMMYFckfui8YMBuUZA' for 1st argument
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, dollar___QX30i9a0JRHUXu5QkLQcZiA)(tyTuple__UV3llMMYFckfui8YMBuUZA x);
^
/Users/timothee/git_clone/nim/Nim_devel/lib/nimbase.h:245:44: note: expanded from macro 'N_NIMCALL'
# define N_NIMCALL(rettype, name) rettype name /* no modifier */
Expected Output
should work
Additional Information
- recent devel f22d3c7
workaround
looks like adding the (redundant-looking) string($foo)
instead of $foo
makes the codegen error go away
const a = $("a", "b")
proc fun() =
const str = string($int)
let b = $(str, "asdf")
fun()