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

nim doc .. on a user project is attempting to run runnableExamples from stdlibs, and failing incorrectly [devel] [regression] #14473

Closed
kaushalmodi opened this issue May 27, 2020 · 2 comments · Fixed by #14439

Comments

@kaushalmodi
Copy link
Contributor

kaushalmodi commented May 27, 2020

nim doc .. is failing because of 2 reasons:

  • runnableExamples are attempted to be run from an imported stdlib (sequtils in this example). This is not expected.
  • While above should not be happening, it is failing for not finding a proc from the imported stdlib module (toSeq from sequtils in this example).

Example

# https://forum.nim-lang.org/t/6382#39363
import std/[sequtils]

# "nim doc t.nim" will work once below line is uncommented
# export sequtils

template doit():untyped =
  ## doit
  ## return output only
  toSeq([1,2,3,4,5])

echo doit()

Current Output

/tmp/kmodi/.cache/nim/t_d/runnableExamples/t_examples1.nim(15, 12) Error: undeclared identifier: 'toSeq'
[runnableExamples] failed: generated file: '/tmp/kmodi/.cache/nim/t_d/runnableExamples/t_group0_examples.nim' group: '(rdoccmd: "", docCmd: "", code: "# autogenerated by docgen\n# source: /home/kmodi/sandbox/nim/bug_reports/nim_doc_over_eager_runnableExamples/t.nim\n# rdoccmd: \nimport r\"/tmp/kmodi/.cache/nim/t_d/runnableExamples/t_examples1.nim\"\n", index: 0)' cmd: /home/kmodi/usr_local/apps/6/nim/devel/bin/nim c -r --warning:UnusedImport:off --path:/home/kmodi/sandbox/nim/bug_reports/nim_doc_over_eager_runnableExamples --nimcache:/tmp/kmodi/.cache/nim/t_d/runnableExamples   /tmp/kmodi/.cache/nim/t_d/runnableExamples/t_group0_examples.nim

Expected Output

# (no runnable examples should be running from stdlibs or imported nimble packages)
@[1, 2, 3, 4, 5]

Additional Information

$ nim -v
Nim Compiler Version 1.3.5 [Linux: amd64]
Compiled at 2020-05-26
Copyright (c) 2006-2020 by Andreas Rumpf

git hash: 2a4a43b05fa3fa6ad3f85543ccfbd9ea450c9be0
active boot switches: -d:release
@kaushalmodi kaushalmodi changed the title nim doc .. is running runnableExamples from stdlibs [devel] [regression] nim doc .. on a user project is attempting to run runnableExamples from stdlibs, and failing incorrectly [devel] [regression] May 27, 2020
@kaushalmodi
Copy link
Contributor Author

I confirm that pulling to the latest devel as of now (1fc40db) and then reverting just f96555b fixes this regression.

@timotheecour
Copy link
Member

timotheecour commented May 27, 2020

@kaushalmodi indeed; this should be fixed in #14439 (I just tried), can you confirm on your end and also for your project that #14439 works?

I can revert #14441 also if #14439 will take too long to merge

timotheecour added a commit to timotheecour/Nim that referenced this issue May 28, 2020
timotheecour added a commit to timotheecour/Nim that referenced this issue May 28, 2020
Araq pushed a commit that referenced this issue May 28, 2020
…als, and all formatting; other bug fix (#14439)

* fix #8871 runnableExamples now preserves source code comments, litterals, and all formatting
* remove orig deadcode from getAllRunnableExamplesImpl
* fix expected examples
* add test to close #14473
* correctly handle regular comments before 1st token inside runnableExamples
* add test to answer #14439 (comment)
* update tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants