Merge pull request #4488 from mbaulch/fix4346improved
Use target field types in tuple conversions.
This commit is contained in:
commit
622ab7089c
2 changed files with 25 additions and 0 deletions
|
|
@ -198,6 +198,8 @@ proc semConv(c: PContext, n: PNode): PNode =
|
|||
# separate proc from fitNode?
|
||||
if op.kind == nkSym and op.sym.isGenericRoutine:
|
||||
result.sons[1] = fitNode(c, result.typ, result.sons[1])
|
||||
elif op.kind == nkPar and targetType.kind == tyTuple:
|
||||
op = fitNode(c, targetType, op)
|
||||
of convNotNeedeed:
|
||||
message(n.info, hintConvFromXtoItselfNotNeeded, result.typ.typeToString)
|
||||
of convNotLegal:
|
||||
|
|
|
|||
23
tests/tuples/tconver_tuple.nim
Normal file
23
tests/tuples/tconver_tuple.nim
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
# 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
|
||||
|
||||
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