syntax compatibility between do blocks and stmt blocks
See the section `do notation` in the manual for more info. * nkMacroStmt has been removed Macro statements are now mapped to regular nkCall nodes. The support for additional clauses (such as else, except, of, etc) have been restored - they will now appear as additional arguments for the nkCall node (as nkElse, nkExcept, etc nodes) * fixed some regressions in the `is` operator and semCompiles
This commit is contained in:
parent
a6d5707faf
commit
d9d82fb0af
21 changed files with 142 additions and 168 deletions
|
|
@ -28,12 +28,12 @@ import
|
|||
# `opened` is defined to `optional.hasValue`
|
||||
macro using(e: expr): stmt {.immediate.} =
|
||||
let e = callsite()
|
||||
if e.len != 2:
|
||||
if e.len != 3:
|
||||
error "Using statement: unexpected number of arguments. Got " &
|
||||
$e.len & ", expected: 1 or more variable assignments and a block"
|
||||
|
||||
var args = e[0]
|
||||
var body = e[1]
|
||||
var args = e
|
||||
var body = e[2]
|
||||
|
||||
var
|
||||
variables : seq[PNimrodNode]
|
||||
|
|
@ -41,8 +41,8 @@ macro using(e: expr): stmt {.immediate.} =
|
|||
|
||||
newSeq(variables, 0)
|
||||
newSeq(closingCalls, 0)
|
||||
|
||||
for i in countup(1, args.len-1):
|
||||
|
||||
for i in countup(1, args.len-2):
|
||||
if args[i].kind == nnkExprEqExpr:
|
||||
var varName = args[i][0]
|
||||
var varValue = args[i][1]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue