Skip to content

Commit

Permalink
fix when statements in inheritable generic objects (#13667) [backport]
Browse files Browse the repository at this point in the history
  • Loading branch information
Jasper Jenkins authored Mar 17, 2020
1 parent 122751a commit 51bd442
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion compiler/semtypes.nim
Original file line number Diff line number Diff line change
Expand Up @@ -804,7 +804,7 @@ proc addInheritedFieldsAux(c: PContext, check: var IntSet, pos: var int,
addInheritedFieldsAux(c, check, pos, lastSon(n[i]))
else: internalError(c.config, n.info, "addInheritedFieldsAux(record case branch)")
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])
of nkSym:
incl(check, n.sym.name.id)
Expand Down
11 changes: 11 additions & 0 deletions tests/objects/tobject3.nim
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,14 @@ proc newArrayAnimationSampler*[T](): ArrayAnimationSampler[T] =

discard newArrayAnimationSampler[Foo6]()
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]

0 comments on commit 51bd442

Please sign in to comment.