diff options
author | Ico Doornekamp <github@zevv.nl> | 2019-01-18 09:04:12 +0100 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2019-01-18 09:04:12 +0100 |
commit | f11f36e7d5c2dc9a8f13f84ead360369fb05eaf3 (patch) | |
tree | 966c7fe81713c1ceb718f8fe1328887075eb59ee /lib/core | |
parent | 27e2ed4375c21b196f5fd403c2199c63dcdb8bf0 (diff) | |
download | Nim-f11f36e7d5c2dc9a8f13f84ead360369fb05eaf3.tar.gz |
Fixed getCustomPragmaVal to allow multiple fields in custom annotations (#10289)
Diffstat (limited to 'lib/core')
-rw-r--r-- | lib/core/macros.nim | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/lib/core/macros.nim b/lib/core/macros.nim index 08ee05152..3a85324ba 100644 --- a/lib/core/macros.nim +++ b/lib/core/macros.nim @@ -1500,9 +1500,18 @@ macro getCustomPragmaVal*(n: typed, cp: typed{nkSym}): untyped = let pragmaNode = customPragmaNode(n) for p in pragmaNode: if p.kind in nnkPragmaCallKinds and p.len > 0 and p[0].kind == nnkSym and p[0] == cp: - return p[1] - - error(n.repr & " doesn't have a pragma named " & cp.repr()) # returning an empty node results in most cases in a cryptic error, + if p.len == 2: + result = p[1] + else: + let def = p[0].getImpl[3] + result = newTree(nnkPar) + for i in 1..<p.len: + let key = def[i][0] + let val = p[i] + result.add newTree(nnkExprColonExpr, key, val) + break + if result.kind == nnkEmpty: + error(n.repr & " doesn't have a pragma named " & cp.repr()) # returning an empty node results in most cases in a cryptic error, when not defined(booting): |