summary refs log tree commit diff stats
path: root/lib/core
diff options
context:
space:
mode:
authorb3liever <43617260+b3liever@users.noreply.github.com>2020-01-07 12:25:51 +0200
committerAndreas Rumpf <rumpf_a@web.de>2020-01-07 11:25:51 +0100
commit8bcc7e8b9ea39524bac14f6c89de5213509f4099 (patch)
tree3c05688c25943e7c68105a9251d59f0ba1bd2ab3 /lib/core
parent291608045c17042cc4e13c9454078e15ecf9510f (diff)
downloadNim-8bcc7e8b9ea39524bac14f6c89de5213509f4099.tar.gz
basename supports pragmaexpr (#13045)
* basename supports pragmaexpr

* update changelog
Diffstat (limited to 'lib/core')
-rw-r--r--lib/core/macros.nim6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/core/macros.nim b/lib/core/macros.nim
index b513be403..f97b4a15f 100644
--- a/lib/core/macros.nim
+++ b/lib/core/macros.nim
@@ -1328,8 +1328,9 @@ proc insert*(a: NimNode; pos: int; b: NimNode) {.compileTime.} =
 proc basename*(a: NimNode): NimNode =
   ## Pull an identifier from prefix/postfix expressions.
   case a.kind
-  of nnkIdent: return a
-  of nnkPostfix, nnkPrefix: return a[1]
+  of nnkIdent: result = a
+  of nnkPostfix, nnkPrefix: result = a[1]
+  of nnkPragmaExpr: result = basename(a[0])
   else:
     error("Do not know how to get basename of (" & treeRepr(a) & ")\n" &
       repr(a), a)
@@ -1340,6 +1341,7 @@ proc `basename=`*(a: NimNode; val: string) {.compileTime.}=
     a.strVal = val
   of nnkPostfix, nnkPrefix:
     a[1] = ident(val)
+  of nnkPragmaExpr: `basename=`(a[0], val)
   else:
     error("Do not know how to get basename of (" & treeRepr(a) & ")\n" &
       repr(a), a)