fixes #1901
This commit is contained in:
parent
fd10866ae3
commit
9dfd8fea12
1 changed files with 8 additions and 7 deletions
|
|
@ -392,7 +392,7 @@ proc genRecordFieldsAux(m: BModule, n: PNode,
|
||||||
uname = toRope(mangle(n.sons[0].sym.name.s) & 'U')
|
uname = toRope(mangle(n.sons[0].sym.name.s) & 'U')
|
||||||
if accessExpr != nil: ae = ropef("$1.$2", [accessExpr, uname])
|
if accessExpr != nil: ae = ropef("$1.$2", [accessExpr, uname])
|
||||||
else: ae = uname
|
else: ae = uname
|
||||||
app(result, "union {" & tnl)
|
var unionBody: PRope = nil
|
||||||
for i in countup(1, sonsLen(n) - 1):
|
for i in countup(1, sonsLen(n) - 1):
|
||||||
case n.sons[i].kind
|
case n.sons[i].kind
|
||||||
of nkOfBranch, nkElse:
|
of nkOfBranch, nkElse:
|
||||||
|
|
@ -402,13 +402,14 @@ proc genRecordFieldsAux(m: BModule, n: PNode,
|
||||||
a = genRecordFieldsAux(m, k, ropef("$1.$2", [ae, sname]), rectype,
|
a = genRecordFieldsAux(m, k, ropef("$1.$2", [ae, sname]), rectype,
|
||||||
check)
|
check)
|
||||||
if a != nil:
|
if a != nil:
|
||||||
app(result, "struct {")
|
app(unionBody, "struct {")
|
||||||
app(result, a)
|
app(unionBody, a)
|
||||||
appf(result, "} $1;$n", [sname])
|
appf(unionBody, "} $1;$n", [sname])
|
||||||
else:
|
else:
|
||||||
app(result, genRecordFieldsAux(m, k, ae, rectype, check))
|
app(unionBody, genRecordFieldsAux(m, k, ae, rectype, check))
|
||||||
else: internalError("genRecordFieldsAux(record case branch)")
|
else: internalError("genRecordFieldsAux(record case branch)")
|
||||||
appf(result, "} $1;$n", [uname])
|
if unionBody != nil:
|
||||||
|
appf(result, "union{$n$1} $2;$n", [unionBody, uname])
|
||||||
of nkSym:
|
of nkSym:
|
||||||
field = n.sym
|
field = n.sym
|
||||||
if field.typ.kind == tyEmpty: return
|
if field.typ.kind == tyEmpty: return
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue