diff options
author | ringabout <43030857+ringabout@users.noreply.github.com> | 2024-01-02 14:49:16 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-02 07:49:16 +0100 |
commit | c7d742e484e06cdc8d87443a76ec03f1f1724bee (patch) | |
tree | 66b1bf9ff79bf5706391e93e5164b43bcce1a0b6 | |
parent | b280100499fafe43657c860e3c79d9347be5b4b6 (diff) | |
download | Nim-c7d742e484e06cdc8d87443a76ec03f1f1724bee.tar.gz |
fixes #23148; restricts infix path concatenation to what starts with `/` (#23150)
fixes #23148
-rw-r--r-- | compiler/modulepaths.nim | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/compiler/modulepaths.nim b/compiler/modulepaths.nim index c29ed6793..73e0ef784 100644 --- a/compiler/modulepaths.nim +++ b/compiler/modulepaths.nim @@ -38,11 +38,14 @@ proc getModuleName*(conf: ConfigRef; n: PNode): string = localError(n.info, "only '/' supported with $package notation") result = "" else: - 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 == 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 + else: + result = "" of nkPrefix: when false: if n[0].kind == nkIdent and n[0].ident.s == "$": |