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
in case1, I would expect error message to be something like: bar expected 2 arguments (lambda: untyped, arg:typed) ; got 3
instead, currently the compiler tries to evaluate fun, which fails because it's not meant to be evaluated in this context.
in summary: we should evaluate number of arguments first before any other mismatch logic.
Is there anything blocking this logic? (eg: varargs[untyped] ?)
import macros
macrobar*(lambda: untyped, arg:typed):untyped=dumpTree(lambda)
result=newStmtList()
block:
templatefoo[T](fun: untyped, a:T, b:T): auto=whendefined(case1):
discardbar(fun, a, b)
whendefined(case2):
discardbar(fun, a)
0discardfoo(u1 => u1, 2, 3)
rnim -d:case2 bugs/compiler/t23_errmsg_confusing_with_macro_num_arg_mismatch.nim
nim c --nimcache:/tmp/nim//nimcache/ -o:/tmp/nim//app -r -d:case2 bugs/compiler/t23_errmsg_confusing_with_macro_num_arg_mismatch.nim
Hint: used config file '/Users/timothee/git_clone/nim/Nim/config/nim.cfg' [Conf]
Hint: used config file '/Users/timothee/.config/nim/nim.cfg' [Conf]
Hint: used config file '/Users/timothee/git_clone/nim/timn/nim.cfg' [Conf]
Ident "lambda"
/Users/timothee/git_clone/nim/timn/bugs/compiler/t23_errmsg_confusing_with_macro_num_arg_mismatch.nim(7, 1) template/generic instantiation from here
/Users/timothee/git_clone/nim/timn/bugs/compiler/t23_errmsg_confusing_with_macro_num_arg_mismatch.nim(15, 14) template/generic instantiation from here
/Users/timothee/git_clone/nim/timn/bugs/compiler/t23_errmsg_confusing_with_macro_num_arg_mismatch.nim(12, 18) Error: expression '' has no type (or is ambiguous)
discard bar(fun, a)
^
rnim -d:case1 bugs/compiler/t23_errmsg_confusing_with_macro_num_arg_mismatch.nim
nim c --nimcache:/tmp/nim//nimcache/ -o:/tmp/nim//app -r -d:case1 bugs/compiler/t23_errmsg_confusing_with_macro_num_arg_mismatch.nim
Hint: used config file '/Users/timothee/git_clone/nim/Nim/config/nim.cfg' [Conf]
Hint: used config file '/Users/timothee/.config/nim/nim.cfg' [Conf]
Hint: used config file '/Users/timothee/git_clone/nim/timn/nim.cfg' [Conf]
Ident "lambda"
/Users/timothee/git_clone/nim/timn/bugs/compiler/t23_errmsg_confusing_with_macro_num_arg_mismatch.nim(7, 1) template/generic instantiation from here
/Users/timothee/git_clone/nim/timn/bugs/compiler/t23_errmsg_confusing_with_macro_num_arg_mismatch.nim(15, 18) Error: undeclared identifier: '=>'
discard foo(u1 => u1, 2, 3)
^
The text was updated successfully, but these errors were encountered:
abc.nim(12, 6) Error: type mismatch: got <void, void, void> # `void` can be replaced with something else
but expected one of:
macro hello(x, y: untyped)
expression: hello(apple, banana, orange)
or a more meaningful error message like @timotheecour wants
reduced from a more complex example:
in
case1
, I would expect error message to be something like:bar
expected 2 arguments(lambda: untyped, arg:typed)
; got 3instead, currently the compiler tries to evaluate
fun
, which fails because it's not meant to be evaluated in this context.in summary: we should evaluate number of arguments first before any other mismatch logic.
Is there anything blocking this logic? (eg:
varargs[untyped]
?)The text was updated successfully, but these errors were encountered: