fixes #23167; take nkOpenSymChoice into consideration caused by templates [backport] (#23168)

fixes #23167

(cherry picked from commit 4eaa3b028c)
This commit is contained in:
ringabout
2024-01-05 15:17:08 +08:00
committed by narimiran
parent 0cdca3a0cd
commit c3d043e980
2 changed files with 15 additions and 6 deletions

View File

@@ -36,12 +36,16 @@ proc getModuleName*(conf: ConfigRef; n: PNode): string =
localError(n.info, "only '/' supported with $package notation")
result = ""
else:
if n0.kind == nkIdent and n0.ident.s[0] == '/':
let modname = getModuleName(conf, n[2])
# hacky way to implement 'x / y /../ z':
result = getModuleName(conf, n1)
result.add renderTree(n0, {renderNoComments}).replace(" ")
result.add modname
if n0.kind in nkIdentKinds:
let ident = n0.getPIdent
if ident != nil and ident.s[0] == '/':
let modname = getModuleName(conf, n[2])
# hacky way to implement 'x / y /../ z':
result = getModuleName(conf, n1)
result.add renderTree(n0, {renderNoComments}).replace(" ")
result.add modname
else:
result = ""
else:
result = ""
of nkPrefix:

5
tests/import/t23167.nim Normal file
View File

@@ -0,0 +1,5 @@
# bug #23167
template sharedImport() =
import std / os
sharedImport()