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

[superseded] macros.parseStmt,parseExpr: show erroneous code on error #9853

Closed
wants to merge 3 commits into
base: devel
from

Conversation

Projects
None yet
2 participants
@timotheecour
Collaborator

timotheecour commented Dec 4, 2018

previously, parseStmt didn't show s when it failed, resulting in cryptic errors in complex cases (eg where s is generated from some code); now it shows it:

../../../Nim/lib/core/macros.nim(519) parseStmt
/pathto/bar.nim(24, 1) template/generic instantiation from here
/pathto/bar.nim(25, 40) template/generic instantiation of `bam` from here
/Users/timothee/git_clone/nim/Nim/lib/core/macros.nim(519, 5) Error: unhandled exception: internalError: "/Users/timothee/git_clone/nim/Nim/lib/core/macros.nim(515, 12) Error: invalid indentation"
s:
------
import random
var temp = 1
temp.inc
echo temp
random(332))
------
      raise newException(ValueError, msg)
      ^
No stack traceback available
To create a stacktrace, rerun compilation with ./koch temp c <file>

[EDIT] likewise with parseExpr
[EDIT] changed to:

...
macros.nim(514, 5) Error: unhandled exception: parse error: "macros.nim(527, 2) Error: invalid indentation" with:
>let a1 = 2
> a1

@timotheecour timotheecour force-pushed the timotheecour:pr_parseStmt_error branch from ac2048b to a966f41 Dec 4, 2018

Show resolved Hide resolved lib/core/macros.nim Outdated
@timotheecour

This comment has been minimized.

Collaborator

timotheecour commented Dec 5, 2018

PTAL

Show resolved Hide resolved lib/core/macros.nim Outdated

@timotheecour timotheecour force-pushed the timotheecour:pr_parseStmt_error branch from 5e49f2e to 26387b2 Dec 10, 2018

@timotheecour

This comment has been minimized.

Collaborator

timotheecour commented Dec 10, 2018

PTAL:

  • see #9853 (comment) for new formatting
  • did same with parseExpr
  • added tests

@timotheecour timotheecour changed the title from macros.parseStmt: show erroneous code on error to macros.parseStmt,parseExpr: show erroneous code on error Dec 10, 2018

@timotheecour timotheecour force-pushed the timotheecour:pr_parseStmt_error branch from 26387b2 to 2c1cd87 Dec 10, 2018

@timotheecour timotheecour force-pushed the timotheecour:pr_parseStmt_error branch from 2c1cd87 to 4b3bc06 Dec 10, 2018

@timotheecour

This comment has been minimized.

Collaborator

timotheecour commented Dec 10, 2018

closing temporarily; need to address 1 thing

@timotheecour timotheecour changed the title from macros.parseStmt,parseExpr: show erroneous code on error to [TODO] macros.parseStmt,parseExpr: show erroneous code on error Dec 10, 2018

@timotheecour timotheecour changed the title from [TODO] macros.parseStmt,parseExpr: show erroneous code on error to [superseded] macros.parseStmt,parseExpr: show erroneous code on error Dec 11, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment