summary refs log tree commit diff stats
path: root/tests/generics/tcritical.nim
diff options
context:
space:
mode:
Diffstat (limited to 'tests/generics/tcritical.nim')
-rw-r--r--tests/generics/tcritical.nim19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/generics/tcritical.nim b/tests/generics/tcritical.nim
new file mode 100644
index 000000000..e84c03618
--- /dev/null
+++ b/tests/generics/tcritical.nim
@@ -0,0 +1,19 @@
+discard """
+  errormsg: "type mismatch"
+  line: 18
+"""
+
+# bug #3998
+
+type Vec3[T] = array[3, T]
+
+var vg: Vec3[float32] = Vec3([1.0f, 2.0f, 3.0f])
+
+echo "vg[0]: " & $vg[0]  # prints 1.0    OK
+echo "vg[1]: " & $vg[1]  # prints 2.0    OK
+echo "vg[2]: " & $vg[2]  # prints 3.0    OK
+echo ""
+
+var ve: Vec3[float64]
+ve = vg     # compiles, this MUST NOT be allowed!
+