Skip to content

Commit

Permalink
Fix benchmark runner bug introduced in release 0.652 (#1530)
Browse files Browse the repository at this point in the history
### Problem

In release 0.652, `RequireResolver` was refactored to add support for
`luau-analyze`.

As part of this update, `RuntimeRequireContext` introduced a new
convention where a file's chunkname must be prefixed with `@` (e.g.,
`@./some/path.luau`). This change applies to all chunknames generated
within `RuntimeRequireContext`. However, when a `.luau` file is executed
directly from the command line (e.g., `luau ./my/script.luau`), the
chunkname is still generated with the old `=` prefix (e.g.,
`=./some/path.luau`).

Since `RuntimeRequireContext` no longer recognizes chunknames prefixed
with `=`, any attempt to directly execute a `.luau` file from the
command line fails. For example, running `luau ./my/script.luau` results
in an error stating that the context is unsupported. [This issue also
affects tools like the benchmark
runner](#1525 (comment)),
which rely on direct file execution.

### Solution

Update `runFile` to replace the `=` prefix in generated chunknames with
`@`.
  • Loading branch information
vrn-sn authored Nov 18, 2024
1 parent e905e30 commit c2e4ee0
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion CLI/Repl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,7 @@ 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);
std::string chunkname = "@" + std::string(name);

std::string bytecode = Luau::compile(*source, copts());
int status = 0;
Expand Down

0 comments on commit c2e4ee0

Please sign in to comment.