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
procfun(){.compileTime.} =echo"step2"static: echo"step1"fun() # user error: should've been: `static: fun()`static: echo"step3 (with side effects) that expects step2 to run before"
nim c main.nim prints:
step1
step3 (with side effects) that expects step2 to run before
/Users/timothee/git_clone/nim/timn/tests/nim/all/t0176.nim(8, 1) template/generic instantiation from here
/Users/timothee/git_clone/nim/timn/tests/nim/all/t0176.nim(10, 1) Error: request to generate code for .compileTime proc: fun
fun() # user error: should've been: `static: fun()`
^
expected output:
step1
/Users/timothee/git_clone/nim/timn/tests/nim/all/t0176.nim(8, 1) template/generic instantiation from here
/Users/timothee/git_clone/nim/timn/tests/nim/all/t0176.nim(10, 1) Error: compileTime proc: fun used in a run time context # <= msg can be something like this ****
fun() # user error: should've been: `static: fun()`
^
ie, compilation should stop earlier and not keep going past the point where fun() is used in a non CT context
other confusing example
I faced a situation (nimterop/nimterop#102 (comment)) where the error Error: request to generate code for .compileTime proc: fun was never printed because "step 3" errored as a result of "step 2" not being run at CT; in more complex cases than above simplified example this is hard to diagnose.
The text was updated successfully, but these errors were encountered:
I agree that the error message should be changed, it was quite confusing when I stumbled onto it the first time. Perhaps attempt to use compileTime proc 'fun' at runtime would be a bit more clear?
nim c main.nim
prints:expected output:
ie, compilation should stop earlier and not keep going past the point where
fun()
is used in a non CT contextother confusing example
I faced a situation (nimterop/nimterop#102 (comment)) where the error
Error: request to generate code for .compileTime proc: fun
was never printed because "step 3" errored as a result of "step 2" not being run at CT; in more complex cases than above simplified example this is hard to diagnose.The text was updated successfully, but these errors were encountered: