fixes pragmas reorder (#21205)

This commit is contained in:
ringabout 2023-01-01 17:25:04 +08:00 • committed by GitHub
commit 5b20f0685c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 0 deletions

View file

@ -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": if a.kind == nkExprColonExpr and a[0].kind == nkIdent and a[0].ident.s == "pragma":
# user defined pragma # user defined pragma
decl(a[1]) decl(a[1])
for i in 1..<n.safeLen: deps(n[i])
else: else:
for i in 0..<n.safeLen: deps(n[i]) for i in 0..<n.safeLen: deps(n[i])
of nkMixinStmt, nkBindStmt: discard of nkMixinStmt, nkBindStmt: discard

View file

@ -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