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

runnableExamples block with except on specified error fails with nim doc #12746

Closed
D-Nice opened this issue Nov 26, 2019 · 0 comments · Fixed by #14379
Closed

runnableExamples block with except on specified error fails with nim doc #12746

D-Nice opened this issue Nov 26, 2019 · 0 comments · Fixed by #14379

Comments

@D-Nice
Copy link
Contributor

D-Nice commented Nov 26, 2019

Unable to catch specific exception in runnableExamples, as it causes nim doc to fail, however, a general except works fine.

Example

# this proc on its own works fine with `nim doc`
proc goodProc*() =
  runnableExamples:
    try:
      discard
    except:
    # just the general except will work
      discard

# this proc fails with `nim doc`
proc badProc*() =
  runnableExamples:
    try:
      discard
    except IOError:
      # specifying Error is culprit
      discard

Current Output

/tmp/project # nim doc runnableExcept.nim 
Hint: used config file '/nim/config/nim.cfg' [Conf]
Hint: used config file '/nim/config/nimdoc.cfg' [Conf]
Hint: system [Processing]
Hint: widestrs [Processing]
Hint: io [Processing]
Hint: runnableExcept [Processing]
fatal.nim(39)            sysFatal
Error: unhandled exception: sempass2.nim(394, 19) `b.sons[j].kind == nkType`  [AssertionError]

Additional Information

  • A working alternative is to import unittest and utilize expect
$ nim -v
Nim Compiler Version 1.0.2 [Linux: amd64]
Compiled at 2019-10-22
Copyright (c) 2006-2019 by Andreas Rumpf

git hash: 193b3c66bbeffafaebff166d24b9866f1eaaac0e
active boot switches: -d:release
timotheecour added a commit to timotheecour/Nim that referenced this issue May 17, 2020
Araq pushed a commit that referenced this issue May 17, 2020
EchoPouet pushed a commit to EchoPouet/Nim that referenced this issue Jun 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant