diff options
-rw-r--r-- | lib/pure/json.nim | 2 | ||||
-rw-r--r-- | lib/pure/strscans.nim | 10 | ||||
-rw-r--r-- | lib/pure/sugar.nim | 4 |
3 files changed, 8 insertions, 8 deletions
diff --git a/lib/pure/json.nim b/lib/pure/json.nim index da1b66188..b5fbb5d07 100644 --- a/lib/pure/json.nim +++ b/lib/pure/json.nim @@ -1779,7 +1779,7 @@ proc createConstructor(typeSym, jsonNode: NimNode): NimNode = result = processType(typeSym, obj, jsonNode, false) of nnkTupleTy: result = processType(typeSym, typeSym, jsonNode, false) - of nnkPar: + of nnkPar, nnkTupleConstr: # TODO: The fact that `jsonNode` here works to give a good line number # is weird. Specifying typeSym should work but doesn't. error("Use a named tuple instead of: " & $toStrLit(typeSym), jsonNode) diff --git a/lib/pure/strscans.nim b/lib/pure/strscans.nim index 2bd87837f..f8a0c43ee 100644 --- a/lib/pure/strscans.nim +++ b/lib/pure/strscans.nim @@ -532,7 +532,7 @@ macro scanp*(input, idx: typed; pattern: varargs[untyped]): bool = newEmptyNode(), newEmptyNode()) elif it.kind == nnkPrefix and it[0].eqIdent"+": # x+ is the same as xx* - result = atm(newTree(nnkPar, it[1], newTree(nnkPrefix, ident"*", it[1])), + result = atm(newTree(nnkTupleConstr, it[1], newTree(nnkPrefix, ident"*", it[1])), input, idx, attached) elif it.kind == nnkPrefix and it[0].eqIdent"?": # optional. @@ -583,18 +583,18 @@ macro scanp*(input, idx: typed; pattern: varargs[untyped]): bool = result = (newEmptyNode(), newCall(interf"atom", input, idx, it), !!newCall(interf"nxt", input, idx)) of nnkCurlyExpr: if it.len == 3 and it[1].kind == nnkIntLit and it[2].kind == nnkIntLit: - var h = newTree(nnkPar, it[0]) + var h = newTree(nnkTupleConstr, it[0]) for count in 2i64 .. it[1].intVal: h.add(it[0]) for count in it[1].intVal .. it[2].intVal-1: h.add(newTree(nnkPrefix, ident"?", it[0])) result = atm(h, input, idx, attached) elif it.len == 2 and it[1].kind == nnkIntLit: - var h = newTree(nnkPar, it[0]) + var h = newTree(nnkTupleConstr, it[0]) for count in 2i64 .. it[1].intVal: h.add(it[0]) result = atm(h, input, idx, attached) else: error("invalid pattern") - of nnkPar: - if it.len == 1: + of nnkPar, nnkTupleConstr: + if it.len == 1 and it.kind == nnkPar: result = atm(it[0], input, idx, attached) else: # concatenation: diff --git a/lib/pure/sugar.nim b/lib/pure/sugar.nim index fbeeef095..258b40191 100644 --- a/lib/pure/sugar.nim +++ b/lib/pure/sugar.nim @@ -21,7 +21,7 @@ proc createProcType(p, b: NimNode): NimNode {.compileTime.} = formalParams.add b case p.kind - of nnkPar: + of nnkPar, nnkTupleConstr: for i in 0 ..< p.len: let ident = p[i] var identDefs = newNimNode(nnkIdentDefs) @@ -61,7 +61,7 @@ macro `=>`*(p, b: untyped): untyped = var params: seq[NimNode] = @[newIdentNode("auto")] case p.kind - of nnkPar: + of nnkPar, nnkTupleConstr: for c in children(p): var identDefs = newNimNode(nnkIdentDefs) case c.kind |