Use target field types in tuple conversions.
This commit is contained in:
parent
813828f690
commit
de41649b0e
2 changed files with 23 additions and 0 deletions
|
|
@ -198,6 +198,10 @@ 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:
|
||||||
|
# Set type of each field in case any have type 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:
|
||||||
|
|
|
||||||
19
tests/tuples/tconver_tuple.nim
Normal file
19
tests/tuples/tconver_tuple.nim
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
# Bug 4479
|
||||||
|
|
||||||
|
type
|
||||||
|
MyTuple = tuple
|
||||||
|
num: int
|
||||||
|
strings: seq[string]
|
||||||
|
ints: seq[int]
|
||||||
|
|
||||||
|
var foo = MyTuple((
|
||||||
|
num: 7,
|
||||||
|
strings: @[],
|
||||||
|
ints: @[],
|
||||||
|
))
|
||||||
|
|
||||||
|
var bar = (
|
||||||
|
num: 7,
|
||||||
|
strings: @[],
|
||||||
|
ints: @[],
|
||||||
|
).MyTuple
|
||||||
Loading…
Add table
Add a link
Reference in a new issue