Handle tuples with unnamed fields, symbols, and more. Less duplication.
This commit is contained in:
parent
05486957d4
commit
915185dd11
2 changed files with 6 additions and 5 deletions
|
|
@ -198,11 +198,8 @@ proc semConv(c: PContext, n: PNode): PNode =
|
||||||
# separate proc from fitNode?
|
# separate proc from fitNode?
|
||||||
if op.kind == nkSym and op.sym.isGenericRoutine:
|
if op.kind == nkSym and op.sym.isGenericRoutine:
|
||||||
result.sons[1] = fitNode(c, result.typ, result.sons[1])
|
result.sons[1] = fitNode(c, result.typ, result.sons[1])
|
||||||
elif op.kind == nkPar and targetType.kind == tyTuple and
|
elif op.kind == nkPar and targetType.kind == tyTuple:
|
||||||
op.sons.len > 0 and op.sons[0].kind == nkExprColonExpr:
|
op = fitNode(c, targetType, op)
|
||||||
# Tuple conversion: set field types in case any are tyEmpty (eg. `@[]`)
|
|
||||||
for i in 0..<op.sons.len:
|
|
||||||
op.sons[i][1].typ = targetType.sons[i]
|
|
||||||
of convNotNeedeed:
|
of convNotNeedeed:
|
||||||
message(n.info, hintConvFromXtoItselfNotNeeded, result.typ.typeToString)
|
message(n.info, hintConvFromXtoItselfNotNeeded, result.typ.typeToString)
|
||||||
of convNotLegal:
|
of convNotLegal:
|
||||||
|
|
|
||||||
|
|
@ -17,3 +17,7 @@ var bar = (
|
||||||
strings: @[],
|
strings: @[],
|
||||||
ints: @[],
|
ints: @[],
|
||||||
).MyTuple
|
).MyTuple
|
||||||
|
|
||||||
|
var fooUnnamed = MyTuple((7, @[], @[]))
|
||||||
|
var n = 7
|
||||||
|
var fooSym = MyTuple((num: n, strings: @[], ints: @[]))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue