From 50f32a1400ab028f6574d59101f3ec21d18233e1 Mon Sep 17 00:00:00 2001 From: Varun Saini <61795485+vrn-sn@users.noreply.github.com> Date: Sun, 13 Apr 2025 10:31:45 -0700 Subject: [PATCH] Do not store file extensions in module chunknames [Luau CLI] (#1772) --- CLI/src/Repl.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/CLI/src/Repl.cpp b/CLI/src/Repl.cpp index 56d9cf8b..9fb1221f 100644 --- a/CLI/src/Repl.cpp +++ b/CLI/src/Repl.cpp @@ -581,7 +581,14 @@ static bool runFile(const char* name, lua_State* GL, bool repl) // new thread needs to have the globals sandboxed luaL_sandboxthread(L); - std::string chunkname = "@" + std::string(name); + // ignore file extension when storing module's chunkname + std::string chunkname = "@"; + std::string_view nameView = name; + if (size_t dotPos = nameView.find_last_of('.'); dotPos != std::string_view::npos) + { + nameView.remove_suffix(nameView.size() - dotPos); + } + chunkname += nameView; std::string bytecode = Luau::compile(*source, copts()); int status = 0;