summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorChris Heller <chris.heller@greyheller.com>2015-03-02 17:02:43 -0800
committerChris Heller <chris.heller@greyheller.com>2015-03-02 17:02:43 -0800
commitdf7e388e0c226731be3c46be7aad2d9993599a9e (patch)
treefa9ef9139701182f24eed728fe86522198cbb4d6
parentf4e0f64f8648dc0dc56f91982b95ae3ff0466539 (diff)
downloadNim-df7e388e0c226731be3c46be7aad2d9993599a9e.tar.gz
Make macros.nim expectKind error message with a single TNimrodNodeKind consistent with error message shown with a set of TNimrodNodeKind by displaying the actual node kind (as well as the expected)
-rw-r--r--lib/core/macros.nim6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/core/macros.nim b/lib/core/macros.nim
index 4758dc0c1..519bae209 100644
--- a/lib/core/macros.nim
+++ b/lib/core/macros.nim
@@ -339,11 +339,13 @@ proc quote*(bl: stmt, op = "``"): PNimrodNode {.magic: "QuoteAst", noSideEffect.
   ##       if not `ex`:
   ##         echo `info` & ": Check failed: " & `expString`
 
+from strutils import cmpIgnoreStyle, format
+
 proc expectKind*(n: PNimrodNode, k: TNimrodNodeKind) {.compileTime.} =
   ## checks that `n` is of kind `k`. If this is not the case,
   ## compilation aborts with an error message. This is useful for writing
   ## macros that check the AST that is passed to them.
-  if n.kind != k: error("macro expects a node of kind: " & $k)
+  if n.kind != k: error("Expected a node of kind $1, got $2".format(k, n.kind))
 
 proc expectMinLen*(n: PNimrodNode, min: int) {.compileTime.} =
   ## checks that `n` has at least `min` children. If this is not the case,
@@ -581,8 +583,6 @@ const
   CallNodes* = {nnkCall, nnkInfix, nnkPrefix, nnkPostfix, nnkCommand,
     nnkCallStrLit, nnkHiddenCallConv}
 
-from strutils import cmpIgnoreStyle, format
-
 proc expectKind*(n: PNimrodNode; k: set[TNimrodNodeKind]) {.compileTime.} =
   assert n.kind in k, "Expected one of $1, got $2".format(k, n.kind)