summary refs log tree commit diff stats
path: root/tests/array/tarrayplus.nim
diff options
context:
space:
mode:
Diffstat (limited to 'tests/array/tarrayplus.nim')
-rw-r--r--tests/array/tarrayplus.nim13
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/array/tarrayplus.nim b/tests/array/tarrayplus.nim
new file mode 100644
index 000000000..0ea349f4f
--- /dev/null
+++ b/tests/array/tarrayplus.nim
@@ -0,0 +1,13 @@
+discard """
+  errormsg: "type mismatch: got (array[0..2, float], array[0..1, float])"
+"""
+
+proc `+`*[R, T] (v1, v2: array[R, T]): array[R, T] =
+  for i in low(v1)..high(v1):
+    result[i] = v1[i] + v2[i]
+
+var 
+  v1: array[0..2, float] = [3.0, 1.2, 3.0]
+  v2: array[0..1, float] = [2.0, 1.0]
+  v3 = v1 + v2
+