summary refs log tree commit diff stats
path: root/tests/objects/tobject.nim
diff options
context:
space:
mode:
authorTimothee Cour <timothee.cour2@gmail.com>2020-07-27 13:32:21 -0700
committerGitHub <noreply@github.com>2020-07-27 22:32:21 +0200
commit377f71676629d5621d052e662996d30323ea3bee (patch)
tree1b00151a6428b2df1a74ddc090ef400f5636863c /tests/objects/tobject.nim
parentcac09a43aea0e8bcc6a7f2634cfcd4274a260b49 (diff)
downloadNim-377f71676629d5621d052e662996d30323ea3bee.tar.gz
fix #14698 nkRecWhen caused internalAssert in semConstructFields when generic type not mentioned in fields (#14709)
* fix #14698 nkRecWhen caused internalAssert in semConstructFields when generic type not mentioned in fields

* address comment

* Update compiler/semtypinst.nim

Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
Diffstat (limited to 'tests/objects/tobject.nim')
-rw-r--r--tests/objects/tobject.nim20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/objects/tobject.nim b/tests/objects/tobject.nim
index 34856eaef..a79c2bdfd 100644
--- a/tests/objects/tobject.nim
+++ b/tests/objects/tobject.nim
@@ -42,3 +42,23 @@ var b: TMyObj = a
 type
   InheritableFoo {.inheritable.} = ref object
   InheritableBar = ref object of InheritableFoo # ERROR.
+
+block: # bug #14698
+  const N = 3
+  type Foo[T] = ref object
+    x1: int
+    when N == 2:
+      x2: float
+    when N == 3:
+      x3: seq[int]
+    else:
+      x4: char
+      x4b: array[9, char]
+
+  let t = Foo[float](x1: 1)
+  doAssert $(t[]) == "(x1: 1, x3: @[])"
+  doAssert t.sizeof == int.sizeof
+  type Foo1 = object
+    x1: int
+    x3: seq[int]
+  doAssert t[].sizeof == Foo1.sizeof