summary refs log tree commit diff stats
path: root/tests
diff options
context:
space:
mode:
authorJake Leahy <jake@leahy.dev>2023-01-12 12:44:33 +1100
committerGitHub <noreply@github.com>2023-01-11 20:44:33 -0500
commit1e52423774e81f71d10a712575fd65231705362e (patch)
tree5acb908b0437cd3294114f110ada030add69df61 /tests
parente4e947232b9e054cd55c9fefe3ea97f47619a5ca (diff)
downloadNim-1e52423774e81f71d10a712575fd65231705362e.tar.gz
Fix getting custom pragma from generic object (#20481)
* Merge devel

Add another test case

* Fix test

Use getCustomPragmaVal instead of hasCustomPragma

Co-authored-by: Clay Sweetser <Varriount@users.noreply.github.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/stdlib/tmacros.nim18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/stdlib/tmacros.nim b/tests/stdlib/tmacros.nim
index 7ec2fed9f..c054b66c7 100644
--- a/tests/stdlib/tmacros.nim
+++ b/tests/stdlib/tmacros.nim
@@ -157,3 +157,21 @@ block: # bug #19020
   static:
     doAssert $bar.getCustomPragmaVal(typ) == "foo"
   doAssert $bar.getCustomPragmaVal(typ) == "foo"
+
+block hasCustomPragmaGeneric:
+  template examplePragma() {.pragma.}
+  type
+    Foo[T] {.examplePragma.} = object
+      x {.examplePragma.}: T
+  var f: Foo[string]
+  doAssert f.hasCustomPragma(examplePragma)
+  doAssert f.x.hasCustomPragma(examplePragma)
+
+block getCustomPragmaValGeneric:
+  template examplePragma(x: int) {.pragma.}
+  type
+    Foo[T] {.examplePragma(42).} = object
+      x {.examplePragma(25).}: T
+  var f: Foo[string]
+  doAssert f.getCustomPragmaVal(examplePragma) == 42
+  doAssert f.x.getCustomPragmaVal(examplePragma) == 25