Skip to content

Commit

Permalink
fixes pragmas reorder (nim-lang#21205)
Browse files Browse the repository at this point in the history
  • Loading branch information
ringabout authored and survivorm committed Feb 28, 2023
1 parent 40fdb65 commit 0afc227
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions compiler/reorder.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 19 additions & 0 deletions tests/pragmas/tpragmas_reorder.nim
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 0afc227

Please sign in to comment.