From 0acdce502ca39441bb7e4050efdf43bf03db075d Mon Sep 17 00:00:00 2001 From: ringabout <43030857+ringabout@users.noreply.github.com> Date: Tue, 2 Jan 2024 14:49:16 +0800 Subject: [PATCH] fixes #23148; restricts infix path concatenation to what starts with `/` (#23150) fixes #23148 (cherry picked from commit c7d742e484e06cdc8d87443a76ec03f1f1724bee) --- compiler/modulepaths.nim | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/compiler/modulepaths.nim b/compiler/modulepaths.nim index e80ea3fa66..fa8fab08a2 100644 --- a/compiler/modulepaths.nim +++ b/compiler/modulepaths.nim @@ -36,11 +36,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 == "$":