summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorringabout <43030857+ringabout@users.noreply.github.com>2023-01-01 17:25:04 +0800
committerGitHub <noreply@github.com>2023-01-01 10:25:04 +0100
commit5b20f0685c71e68ab08f7a1941f7e160d91e538f (patch)
tree92f05e546316a9b3f388e294a1fefe5be8904793
parent4032eb4baafcfb4a1cb8fd41a474daac70103856 (diff)
downloadNim-5b20f0685c71e68ab08f7a1941f7e160d91e538f.tar.gz
fixes pragmas reorder (#21205)
-rw-r--r--compiler/reorder.nim1
-rw-r--r--tests/pragmas/tpragmas_reorder.nim19
2 files changed, 20 insertions, 0 deletions
diff --git a/compiler/reorder.nim b/compiler/reorder.nim
index 4fabf9041..4ad3f1219 100644
--- a/compiler/reorder.nim
+++ b/compiler/reorder.nim
@@ -106,6 +106,7 @@ proc computeDeps(cache: IdentCache; n: PNode, declares, uses: var IntSet; topLev
     if a.kind == nkExprColonExpr and a[0].kind == nkIdent and a[0].ident.s == "pragma":
       # user defined pragma
       decl(a[1])
+      for i in 1..<n.safeLen: deps(n[i])
     else:
       for i in 0..<n.safeLen: deps(n[i])
   of nkMixinStmt, nkBindStmt: discard
diff --git a/tests/pragmas/tpragmas_reorder.nim b/tests/pragmas/tpragmas_reorder.nim
new file mode 100644
index 000000000..c4b1a6b0a
--- /dev/null
+++ b/tests/pragmas/tpragmas_reorder.nim
@@ -0,0 +1,19 @@
+discard """
+  matrix: "--experimental:codeReordering"
+"""
+
+runnableExamples:
+  import strtabs
+  var t = newStringTable()
+  t["name"] = "John"
+  t["city"] = "Monaco"
+  doAssert t.len == 2
+  doAssert t.hasKey "name"
+  doAssert "name" in t
+
+include "system/inclrtl"
+
+{.pragma: rtlFunc, rtl.}
+
+proc hasKey*(): bool {.rtlFunc.} =
+  discard
\ No newline at end of file
href='#n175'>175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241