parent
c47d5196be
commit
e98efdcc5e
2 changed files with 25 additions and 3 deletions
|
|
@ -777,9 +777,10 @@ proc semRecordNodeAux(c: PContext, n: PNode, check: var IntSet, pos: var int,
|
||||||
if n == nil: return
|
if n == nil: return
|
||||||
case n.kind
|
case n.kind
|
||||||
of nkRecWhen:
|
of nkRecWhen:
|
||||||
|
var a = copyTree(n)
|
||||||
var branch: PNode = nil # the branch to take
|
var branch: PNode = nil # the branch to take
|
||||||
for i in 0..<n.len:
|
for i in 0..<a.len:
|
||||||
var it = n[i]
|
var it = a[i]
|
||||||
if it == nil: illFormedAst(n, c.config)
|
if it == nil: illFormedAst(n, c.config)
|
||||||
var idx = 1
|
var idx = 1
|
||||||
case it.kind
|
case it.kind
|
||||||
|
|
@ -805,7 +806,7 @@ proc semRecordNodeAux(c: PContext, n: PNode, check: var IntSet, pos: var int,
|
||||||
semRecordNodeAux(c, it[idx], newCheck, newPos, newf, rectype, hasCaseFields)
|
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 a
|
||||||
elif branch != nil:
|
elif branch != nil:
|
||||||
semRecordNodeAux(c, branch, check, pos, father, rectype, hasCaseFields)
|
semRecordNodeAux(c, branch, check, pos, father, rectype, hasCaseFields)
|
||||||
elif father.kind in {nkElse, nkOfBranch}:
|
elif father.kind in {nkElse, nkOfBranch}:
|
||||||
|
|
|
||||||
21
tests/generics/t16639.nim
Normal file
21
tests/generics/t16639.nim
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
discard """
|
||||||
|
action: compile
|
||||||
|
"""
|
||||||
|
|
||||||
|
type Foo[T] = object
|
||||||
|
when true:
|
||||||
|
x: float
|
||||||
|
|
||||||
|
type Bar = object
|
||||||
|
when true:
|
||||||
|
x: float
|
||||||
|
|
||||||
|
import std/macros
|
||||||
|
import std/assertions
|
||||||
|
|
||||||
|
macro test() =
|
||||||
|
let a = getImpl(bindSym"Foo")[^1]
|
||||||
|
let b = getImpl(bindSym"Bar")[^1]
|
||||||
|
doAssert treeRepr(a) == treeRepr(b)
|
||||||
|
|
||||||
|
test()
|
||||||
Loading…
Add table
Add a link
Reference in a new issue