parent
c8418651b1
commit
46bfb590c8
2 changed files with 21 additions and 5 deletions
|
|
@ -698,7 +698,7 @@ proc semRecordCase(c: PContext, n: PNode, check: var IntSet, pos: var int,
|
||||||
father.add a
|
father.add a
|
||||||
|
|
||||||
proc semRecordNodeAux(c: PContext, n: PNode, check: var IntSet, pos: var int,
|
proc semRecordNodeAux(c: PContext, n: PNode, check: var IntSet, pos: var int,
|
||||||
father: PNode, rectype: PType, hasCaseFields = false) =
|
father: PNode, rectype: PType, hasCaseFields: bool) =
|
||||||
if n == nil: return
|
if n == nil: return
|
||||||
case n.kind
|
case n.kind
|
||||||
of nkRecWhen:
|
of nkRecWhen:
|
||||||
|
|
@ -727,12 +727,12 @@ proc semRecordNodeAux(c: PContext, n: PNode, check: var IntSet, pos: var int,
|
||||||
assign(newCheck, check)
|
assign(newCheck, check)
|
||||||
var newPos = pos
|
var newPos = pos
|
||||||
var newf = newNodeI(nkRecList, n.info)
|
var newf = newNodeI(nkRecList, n.info)
|
||||||
semRecordNodeAux(c, it[idx], newCheck, newPos, newf, rectype)
|
semRecordNodeAux(c, it[idx], newCheck, newPos, newf, rectype, hasCaseFields)
|
||||||
it[idx] = if newf.len == 1: newf[0] else: newf
|
it[idx] = if newf.len == 1: newf[0] else: newf
|
||||||
if c.inGenericContext > 0:
|
if c.inGenericContext > 0:
|
||||||
father.add n
|
father.add n
|
||||||
elif branch != nil:
|
elif branch != nil:
|
||||||
semRecordNodeAux(c, branch, check, pos, father, rectype)
|
semRecordNodeAux(c, branch, check, pos, father, rectype, hasCaseFields)
|
||||||
of nkRecCase:
|
of nkRecCase:
|
||||||
semRecordCase(c, n, check, pos, father, rectype)
|
semRecordCase(c, n, check, pos, father, rectype)
|
||||||
of nkNilLit:
|
of nkNilLit:
|
||||||
|
|
@ -741,7 +741,7 @@ proc semRecordNodeAux(c: PContext, n: PNode, check: var IntSet, pos: var int,
|
||||||
# attempt to keep the nesting at a sane level:
|
# attempt to keep the nesting at a sane level:
|
||||||
var a = if father.kind == nkRecList: father else: copyNode(n)
|
var a = if father.kind == nkRecList: father else: copyNode(n)
|
||||||
for i in 0..<n.len:
|
for i in 0..<n.len:
|
||||||
semRecordNodeAux(c, n[i], check, pos, a, rectype)
|
semRecordNodeAux(c, n[i], check, pos, a, rectype, hasCaseFields)
|
||||||
if a != father: father.add a
|
if a != father: father.add a
|
||||||
of nkIdentDefs:
|
of nkIdentDefs:
|
||||||
checkMinSonsLen(n, 3, c.config)
|
checkMinSonsLen(n, 3, c.config)
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ discard """
|
||||||
output: '''
|
output: '''
|
||||||
success
|
success
|
||||||
M1 M2
|
M1 M2
|
||||||
|
ok
|
||||||
'''
|
'''
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
@ -39,7 +40,8 @@ type
|
||||||
var k = PFuture[void]()
|
var k = PFuture[void]()
|
||||||
|
|
||||||
|
|
||||||
##bug #9297
|
##bug #9297 and #13281
|
||||||
|
|
||||||
import strutils
|
import strutils
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
@ -58,6 +60,14 @@ type
|
||||||
of M2: b:float
|
of M2: b:float
|
||||||
of M3: c:cstring
|
of M3: c:cstring
|
||||||
|
|
||||||
|
Helper* {.exportc: "PublicHelper".} = object
|
||||||
|
case isKind: bool
|
||||||
|
of true:
|
||||||
|
formatted: string
|
||||||
|
of false:
|
||||||
|
parsed1: string
|
||||||
|
parsed2: string
|
||||||
|
|
||||||
proc newMyObject(kind: MyKind, val: string): MyObject =
|
proc newMyObject(kind: MyKind, val: string): MyObject =
|
||||||
result = MyObject(kind: kind)
|
result = MyObject(kind: kind)
|
||||||
|
|
||||||
|
|
@ -75,3 +85,9 @@ proc newMyObjectRef(kind: MyKind, val: string): MyObjectRef =
|
||||||
|
|
||||||
|
|
||||||
echo newMyObject(M1, "2").kind, " ", newMyObjectRef(M2, "3").kind
|
echo newMyObject(M1, "2").kind, " ", newMyObjectRef(M2, "3").kind
|
||||||
|
|
||||||
|
|
||||||
|
proc test(c: Helper): string =
|
||||||
|
c.formatted
|
||||||
|
|
||||||
|
echo test(Helper(isKind: true, formatted: "ok"))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue