fix when statements in inheritable generic objects (#13667) [backport]

This commit is contained in:
Jasper Jenkins 2020-03-17 15:44:32 -07:00 • committed by GitHub
commit 51bd442b88
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 1 deletions

View file

@ -804,7 +804,7 @@ proc addInheritedFieldsAux(c: PContext, check: var IntSet, pos: var int,
addInheritedFieldsAux(c, check, pos, lastSon(n[i])) addInheritedFieldsAux(c, check, pos, lastSon(n[i]))
else: internalError(c.config, n.info, "addInheritedFieldsAux(record case branch)") else: internalError(c.config, n.info, "addInheritedFieldsAux(record case branch)")
of nkRecList, nkRecWhen, nkElifBranch, nkElse: of nkRecList, nkRecWhen, nkElifBranch, nkElse:
for i in 0..<n.len: for i in int(n.kind == nkElifBranch)..<n.len:
addInheritedFieldsAux(c, check, pos, n[i]) addInheritedFieldsAux(c, check, pos, n[i])
of nkSym: of nkSym:
incl(check, n.sym.name.id) incl(check, n.sym.name.id)

View file

@ -82,3 +82,14 @@ proc newArrayAnimationSampler*[T](): ArrayAnimationSampler[T] =
discard newArrayAnimationSampler[Foo6]() discard newArrayAnimationSampler[Foo6]()
discard newArrayAnimationSampler[AnotherFoo]() discard newArrayAnimationSampler[AnotherFoo]()
type
DefaultIsNone* = pointer | ptr | ref | proc {.nimcall.} | cstring | cstringArray
OptionKind* {.pure.} = enum None, Some
OptionA* [T] = object of RootObj
when T is DefaultIsNone:
value: T
else:
value: T
kind: OptionKind
SomeA* [T] = object of OptionA[T]