summary refs log tree commit diff stats
path: root/tests
diff options
context:
space:
mode:
authorClyybber <darkmine956@gmail.com>2021-02-02 21:43:02 +0100
committerGitHub <noreply@github.com>2021-02-02 21:43:02 +0100
commite4ad0ae5c41fa847797fb4d25bcabff3cdcb8966 (patch)
tree2cd2f958d2b9464ed9530dcaa7cdf448fc371a3e /tests
parent7b9b76d84069716e5b711076ba71ef77bf8a3338 (diff)
downloadNim-e4ad0ae5c41fa847797fb4d25bcabff3cdcb8966.tar.gz
Add testcase for #16897 (#16917)
Diffstat (limited to 'tests')
-rw-r--r--tests/concepts/tconcepts_issues.nim33
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/concepts/tconcepts_issues.nim b/tests/concepts/tconcepts_issues.nim
index 65f6d4660..ec7612b34 100644
--- a/tests/concepts/tconcepts_issues.nim
+++ b/tests/concepts/tconcepts_issues.nim
@@ -467,3 +467,36 @@ block misc_issues:
   # anyway and will be an error soon.
   var a: Cat = Cat()
   a.sayHello()
+
+
+# bug #16897
+
+type
+  Fp[N: static int, T] = object
+    big: array[N, T]
+
+type
+  QuadraticExt* = concept x
+    ## Quadratic Extension concept (like complex)
+    type BaseField = auto
+    x.c0 is BaseField
+    x.c1 is BaseField
+var address = pointer(nil)
+proc prod(r: var QuadraticExt, b: QuadraticExt) =
+  if address == nil:
+    address = unsafeAddr b
+    prod(r, b)
+  else:
+    assert address == unsafeAddr b
+
+type
+  Fp2[N: static int, T] {.byref.} = object
+    c0, c1: Fp[N, T]
+
+# This should be passed by reference,
+# but concepts do not respect the 24 bytes rule
+# or `byref` pragma.
+var r, b: Fp2[6, uint64]
+
+prod(r, b)
+