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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TODO] on error, we shouldn't discard valuable information #34

Closed
1 task
timotheecour opened this issue Jul 26, 2018 · 5 comments
Closed
1 task

[TODO] on error, we shouldn't discard valuable information #34

timotheecour opened this issue Jul 26, 2018 · 5 comments
Projects

Comments

@timotheecour
Copy link
Contributor

timotheecour commented Jul 26, 2018

follow up from #29: my original bug report was actually only half valid / imprecise (sorry for any confusion!); let me clarify what I think is ideal default behavior:

let's reuse bugs/t59_array_index.nim: same as in #29

inim
馃憫 INim 0.3.1
Nim Compiler Version 0.18.1 [MacOSX: amd64] at /Users/timothee/.nimble/bin/nim
inim> import bugs/t59_array_index
Error: unhandled exception: index out of bounds [IndexError]

the useful context is lost here.

/Users/timothee/git_clone/nim/timn/bugs/t59_array_index.nim(3) t59_array_index
/Users/timothee/git_clone/nim/Nim/lib/system.nim(3597) []
/Users/timothee/git_clone/nim/Nim/lib/system.nim(2807) sysFatal
Error: unhandled exception: index out of bounds [IndexError]

which shows the relevant useful runtime stacktrace
the only non-relevant information, that we can discard, is:
Error: execution of an external program failed: '/tmp/nim//app '

NOTE: this is also how ipython3 does it.

ipython3
Python 3.6.5 (default, Jun 20 2018, 01:40:23)
Type 'copyright', 'credits' or 'license' for more information
IPython 6.1.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import t01_inim_issue_29
['a', 'b', 'c']
a
---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
<ipython-input-1-7cfa22fd8457> in <module>()
----> 1 import t01_inim_issue_29

~/git_clone/nim/timn/tests/python/t01_inim_issue_29.py in <module>()
      2 print(a)
      3 print(a[0])
----> 4 print(a[3])
      5

IndexError: list index out of range
  • TODO: and in their case, they show more source info which could be nice as an enhancement

NOTE: same with inim -s=bugs/t59_array_index.nim, the useful error should be:

inim -s=bugs/t59_array_index.nim
inim_1531876765
/Users/timothee/git_clone/nim/Nim/lib/system.nim(3597) []
/Users/timothee/git_clone/nim/Nim/lib/system.nim(2807) sysFatal
Error: unhandled exception: index out of bounds [IndexError]

ie, only Error: execution of an external program failed: '/private/tmp/inim_1531876765 ' would be discarded

NOTE: the existing behavior is correct in the following case:

inim
馃憫 INim 0.3.1
Nim Compiler Version 0.18.1 [MacOSX: amd64] at /Users/timothee/.nimble/bin/nim
inim> asdf
Error: undeclared identifier: 'asdf'
inim>

since there's no relevant stacktrace

summary

  • for runtime errors (after compilation of given cmd succeeds and program is ran, then errors), show runtime stacktrace (discard just "Error: execution of an external program failed" which actually isn't even part of runtime error, just the wrapping exec cmd)
  • for compile errors, existing behavior (eg just showing: "Error: undeclared identifier: 'asdf'") is problably ok but I need to double check on more complex failures; eg, we problably don't want to filter out "template/generic instantiation from here" compilation error messages since these contain useful information to figure out why compile failed
@AndreiRegiani
Copy link
Member

Pushed fixes to master, please check nimble install inim@#head

  • Runtime errors show relevant stack trace (4 lines)
  • Compilation errors shows single line as before

Works with import foobar, inim -s or inim> .

@timotheecour timotheecour changed the title on error, we shouldn't discard valuable information [TODO] on error, we shouldn't discard valuable information Jul 26, 2018
@timotheecour
Copy link
Contributor Author

timotheecour commented Jul 26, 2018

reopening: the following compilation errors are "relevant" and should not be discarded:

bugs/inim/t01_error_msg_discards.nim:

proc fun(a:int):auto =
  a*2
  3

let b=4
echo fun(2)
inim -s=bugs/inim/t01_error_msg_discards.nim --showHeader:false
Error: undeclared identifier: 'a'
inim>
rnim bugs/inim/t01_error_msg_discards.nim
nim c --nimcache:/tmp/nim//nimcache/ -o:/tmp/nim//app -r bugs/inim/t01_error_msg_discards.nim
/Users/timothee/git_clone/nim/timn/bugs/inim/t01_error_msg_discards.nim(1, 1) template/generic instantiation from here
/Users/timothee/git_clone/nim/timn/bugs/inim/t01_error_msg_discards.nim(2, 4) Error: expression 'a * 2' is of type 'int' and has to be discarded
    a*2
     ^

expected output:

inim -s=bugs/inim/t01_error_msg_discards.nim --showHeader:false
/Users/timothee/git_clone/nim/timn/bugs/inim/t01_error_msg_discards.nim(1, 1) template/generic instantiation from here
/Users/timothee/git_clone/nim/timn/bugs/inim/t01_error_msg_discards.nim(2, 4) Error: expression 'a * 2' is of type 'int' and has to be discarded
    a*2
     ^
inim>

@timotheecour timotheecour reopened this Jul 26, 2018
@AndreiRegiani
Copy link
Member

By compiling your example with Nim 0.18.1 [Linux: amd64] I get:

~ nim c -r bugs/t01_error_msg_discards.nim
Hint: used config file '/home/user/.choosenim/toolchains/nim-#devel/config/nim.cfg' [Conf]
Hint: system [Processing]
Hint: t01_error_msg_discards [Processing]
t01_error_msg_discards.nim(2, 6) Error: expression 'a * 2' is of type 'int' and has to be discarded
~ 

With INim I get same output above:

~ inim -s bugs/t01_error_msg_discards.nim 
馃憫 INim 0.4.1
Nim Compiler Version 0.18.1 [Linux: amd64] at /home/user/.nimble/bin/nim
inim_1533504761.nim(4, 6) Error: expression 'a * 2' is of type 'int' and has to be discarded
~ 

Since it's the same, does seem good enough to close this issue, what do you think? How did you get the arrow thing?

    a*2
     ^

@timotheecour
Copy link
Contributor Author

IIRC, --hint[source]=on

btw: IMO if we have to test on only 1 thing, priority should be given to devel, instead of stable

@0atman 0atman added this to Needs triage in Bug Triage Apr 8, 2020
@Tangdongle
Copy link
Collaborator

@0atman I think we might be able to close this (unless you think otherwise @timotheecour). Unless I'm doing something wrong, I can't get --hints:on to print out more than INim gives me.

@0atman 0atman closed this as completed Sep 7, 2020
Bug Triage automation moved this from Needs triage to Closed Sep 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Bug Triage
  
Closed
Development

No branches or pull requests

4 participants