error proc from macro library could have a node parameter #4915

krux02 opened this Issue Oct 20, 2016 · 1 comment


None yet

2 participants

krux02 commented Oct 20, 2016

When there is something wrong in my DSL, I like to write code that uses expectLen, expectKind, expectMinLen, whenever possible, because these procedures not only check for the condition, but I also get proper highlighting in my editor, where in my DSL I have the wrong node. Sadly there are only a few condition that I can check with this methods, on all other cases where something is wrong with the dsl I have to use error, where I loose the positional information of the node that did something wrong.

If error had a parameter, where I could pass a node, to define the source of the problem, I would instantly have something that covers all use cases of all "expect" functions, and even extends to many more use cases:

proc error(msg: string; n: NimNode = nil) [...]

proc expectKind(n: NimNode; k: NimNodeKind): =
  if n.kind != k:
    error("expected kind: " & $k, n)
Araq commented Oct 20, 2016


@Araq Araq pushed a commit that closed this issue Oct 27, 2016
@jangko jangko fixes #4915 bd560d6
@Araq Araq closed this in bd560d6 Oct 27, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment