diff options
author | Lolo Iccl <oxisccl@gmail.com> | 2019-04-27 20:22:02 +0900 |
---|---|---|
committer | cooldome <cdome@bk.ru> | 2019-04-27 12:22:02 +0100 |
commit | 69755542f48618939b3b43f63dbd59b92c518c61 (patch) | |
tree | 6fd83ad177282abce6189e50029d8ab8d6011595 /lib/core | |
parent | 46ce79723123d3706b124f736cecf6bd5d2bac06 (diff) | |
download | Nim-69755542f48618939b3b43f63dbd59b92c518c61.tar.gz |
add progmas to params of macros.newProc (#11025)
Merging
Diffstat (limited to 'lib/core')
-rw-r--r-- | lib/core/macros.nim | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/core/macros.nim b/lib/core/macros.nim index 7a8755299..6a4c094d0 100644 --- a/lib/core/macros.nim +++ b/lib/core/macros.nim @@ -1076,20 +1076,24 @@ proc expectKind*(n: NimNode; k: set[NimNodeKind]) {.compileTime.} = ## macros that check the AST that is passed to them. if n.kind notin k: error("Expected one of " & $k & ", got " & $n.kind, n) -proc newProc*(name = newEmptyNode(); params: openArray[NimNode] = [newEmptyNode()]; - body: NimNode = newStmtList(), procType = nnkProcDef): NimNode {.compileTime.} = +proc newProc*(name = newEmptyNode(); + params: openArray[NimNode] = [newEmptyNode()]; + body: NimNode = newStmtList(); + procType = nnkProcDef; + pragmas: NimNode = newEmptyNode()): NimNode {.compileTime.} = ## shortcut for creating a new proc ## ## The ``params`` array must start with the return type of the proc, ## followed by a list of IdentDefs which specify the params. if procType notin RoutineNodes: error("Expected one of " & $RoutineNodes & ", got " & $procType) + pragmas.expectKind({nnkEmpty, nnkPragma}) result = newNimNode(procType).add( name, newEmptyNode(), newEmptyNode(), newNimNode(nnkFormalParams).add(params), - newEmptyNode(), # pragmas + pragmas, newEmptyNode(), body) |