Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JS target does not prevent calling compileTime procs #11133

bluenote10 opened this issue Apr 28, 2019 · 0 comments


None yet
2 participants
Copy link

commented Apr 28, 2019

With the C backend, the compiler ensures that {.compileTime.} procs can only called from static code. The JS backend seems to miss that check.


proc test() {.compileTime.} =
  echo "can only be called at compile time?"


Current Output

Compiles successfully using nim js test.nim.

When using nim -r js test.nim:


ReferenceError: test_83003 is not defined
    at Object.<anonymous> (/tmp/test.js:27:1)
    at Module._compile (internal/modules/cjs/loader.js:721:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:732:10)
    at Module.load (internal/modules/cjs/loader.js:620:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:560:12)
    at Function.Module._load (internal/modules/cjs/loader.js:552:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:774:12)
    at executeUserCode (internal/bootstrap/node.js:342:17)
    at startExecution (internal/bootstrap/node.js:276:5)
    at startup (internal/bootstrap/node.js:227:5)

Expected Output

The same as we get with the C backend:

test.nim(4, 1) Error: request to generate code for .compileTime proc: test

Additional Information

$ nim -v
Nim Compiler Version 0.19.9 [Linux: amd64]
Compiled at 2019-04-13
Copyright (c) 2006-2019 by Andreas Rumpf

git hash: f6ad071a46a2bec57db453343d8d8b75d3d16ac2
active boot switches: -d:release
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.