Do not store file extensions in module chunknames [Luau CLI] (#1772)

This commit is contained in:
Varun Saini 2025-04-13 10:31:45 -07:00 committed by GitHub
parent a8d14596e7
commit 50f32a1400
Signed by: DevComp
GPG key ID: B5690EEEBB952194

View file

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