make tests green again

This commit is contained in:
Andreas Rumpf
2018-04-13 17:45:48 +02:00
parent 47335aab41
commit 1d1d6f39a3
3 changed files with 8 additions and 8 deletions

View File

@@ -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)

View File

@@ -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:

View File

@@ -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