summary refs log tree commit diff stats
path: root/tests/pragmas/tused.nim
diff options
context:
space:
mode:
Diffstat (limited to 'tests/pragmas/tused.nim')
-rw-r--r--tests/pragmas/tused.nim43
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/pragmas/tused.nim b/tests/pragmas/tused.nim
new file mode 100644
index 000000000..d0c533f9a
--- /dev/null
+++ b/tests/pragmas/tused.nim
@@ -0,0 +1,43 @@
+discard """
+  nimout: '''
+compile start
+tused.nim(17, 8) Hint: 'echoSub' is declared but not used [XDeclaredButNotUsed]
+compile end'''
+  output: "8\n8"
+  joinable: false
+"""
+
+# not joinable because paths in nimout differ when imported
+static:
+  echo "compile start"
+
+template implementArithOpsOld(T) =
+  proc echoAdd(a, b: T) =
+    echo a + b
+  proc echoSub(a, b: T) =
+    echo a - b
+
+template implementArithOpsNew(T) =
+  proc echoAdd(a, b: T) {.used.} =
+    echo a + b
+  proc echoSub(a, b: T) {.used.} =
+    echo a - b
+
+block:
+  # should produce warning for the unused 'echoSub'
+  implementArithOpsOld(int)
+  echoAdd 3, 5
+
+block:
+  # no warning produced for the unused 'echoSub'
+  implementArithOpsNew(int)
+  echoAdd 3, 5
+
+# issue #9896
+type
+  MyEnum {.used.} = enum
+    Val1, Val2, Val3
+
+
+static:
+  echo "compile end"