Merge branch 'master' into merge

This commit is contained in:
Ariel Weiss 2025-02-28 14:02:33 -08:00
commit 4b3b32a447
50 changed files with 70 additions and 65 deletions

View file

@ -46,9 +46,9 @@ jobs:
- name: make cli - name: make cli
run: | run: |
make -j2 config=sanitize werror=1 luau luau-analyze luau-compile # match config with tests to improve build time make -j2 config=sanitize werror=1 luau luau-analyze luau-compile # match config with tests to improve build time
./luau tests/conformance/assert.lua ./luau tests/conformance/assert.luau
./luau-analyze tests/conformance/assert.lua ./luau-analyze tests/conformance/assert.luau
./luau-compile tests/conformance/assert.lua ./luau-compile tests/conformance/assert.luau
windows: windows:
runs-on: windows-latest runs-on: windows-latest
@ -81,9 +81,9 @@ jobs:
shell: bash # necessary for fail-fast shell: bash # necessary for fail-fast
run: | run: |
cmake --build . --target Luau.Repl.CLI Luau.Analyze.CLI Luau.Compile.CLI --config Debug # match config with tests to improve build time cmake --build . --target Luau.Repl.CLI Luau.Analyze.CLI Luau.Compile.CLI --config Debug # match config with tests to improve build time
Debug/luau tests/conformance/assert.lua Debug/luau tests/conformance/assert.luau
Debug/luau-analyze tests/conformance/assert.lua Debug/luau-analyze tests/conformance/assert.luau
Debug/luau-compile tests/conformance/assert.lua Debug/luau-compile tests/conformance/assert.luau
coverage: coverage:
runs-on: ubuntu-22.04 runs-on: ubuntu-22.04

View file

@ -187,6 +187,11 @@ public:
static bool fixupQuotedString(std::string& data); static bool fixupQuotedString(std::string& data);
static void fixupMultilineString(std::string& data); static void fixupMultilineString(std::string& data);
unsigned int getOffset() const
{
return offset;
}
private: private:
char peekch() const; char peekch() const;
char peekch(unsigned int lookahead) const; char peekch(unsigned int lookahead) const;

View file

@ -645,32 +645,32 @@ TEST_CASE("CodegenSupported")
TEST_CASE("Assert") TEST_CASE("Assert")
{ {
runConformance("assert.lua"); runConformance("assert.luau");
} }
TEST_CASE("Basic") TEST_CASE("Basic")
{ {
runConformance("basic.lua"); runConformance("basic.luau");
} }
TEST_CASE("Buffers") TEST_CASE("Buffers")
{ {
ScopedFastFlag luauBufferBitMethods{FFlag::LuauBufferBitMethods2, true}; ScopedFastFlag luauBufferBitMethods{FFlag::LuauBufferBitMethods2, true};
runConformance("buffers.lua"); runConformance("buffers.luau");
} }
TEST_CASE("Math") TEST_CASE("Math")
{ {
ScopedFastFlag LuauMathLerp{FFlag::LuauMathLerp, true}; ScopedFastFlag LuauMathLerp{FFlag::LuauMathLerp, true};
runConformance("math.lua"); runConformance("math.luau");
} }
TEST_CASE("Tables") TEST_CASE("Tables")
{ {
runConformance( runConformance(
"tables.lua", "tables.luau",
[](lua_State* L) [](lua_State* L)
{ {
lua_pushcfunction( lua_pushcfunction(
@ -699,101 +699,101 @@ TEST_CASE("Tables")
TEST_CASE("PatternMatch") TEST_CASE("PatternMatch")
{ {
runConformance("pm.lua"); runConformance("pm.luau");
} }
TEST_CASE("Sort") TEST_CASE("Sort")
{ {
runConformance("sort.lua"); runConformance("sort.luau");
} }
TEST_CASE("Move") TEST_CASE("Move")
{ {
runConformance("move.lua"); runConformance("move.luau");
} }
TEST_CASE("Clear") TEST_CASE("Clear")
{ {
runConformance("clear.lua"); runConformance("clear.luau");
} }
TEST_CASE("Strings") TEST_CASE("Strings")
{ {
ScopedFastFlag luauStringFormatFixC{DFFlag::LuauStringFormatFixC, true}; ScopedFastFlag luauStringFormatFixC{DFFlag::LuauStringFormatFixC, true};
runConformance("strings.lua"); runConformance("strings.luau");
} }
TEST_CASE("StringInterp") TEST_CASE("StringInterp")
{ {
runConformance("stringinterp.lua"); runConformance("stringinterp.luau");
} }
TEST_CASE("VarArg") TEST_CASE("VarArg")
{ {
runConformance("vararg.lua"); runConformance("vararg.luau");
} }
TEST_CASE("Locals") TEST_CASE("Locals")
{ {
runConformance("locals.lua"); runConformance("locals.luau");
} }
TEST_CASE("Literals") TEST_CASE("Literals")
{ {
runConformance("literals.lua"); runConformance("literals.luau");
} }
TEST_CASE("Errors") TEST_CASE("Errors")
{ {
runConformance("errors.lua"); runConformance("errors.luau");
} }
TEST_CASE("Events") TEST_CASE("Events")
{ {
runConformance("events.lua"); runConformance("events.luau");
} }
TEST_CASE("Constructs") TEST_CASE("Constructs")
{ {
runConformance("constructs.lua"); runConformance("constructs.luau");
} }
TEST_CASE("Closure") TEST_CASE("Closure")
{ {
runConformance("closure.lua"); runConformance("closure.luau");
} }
TEST_CASE("Calls") TEST_CASE("Calls")
{ {
ScopedFastFlag LuauStackLimit{DFFlag::LuauStackLimit, true}; ScopedFastFlag LuauStackLimit{DFFlag::LuauStackLimit, true};
runConformance("calls.lua"); runConformance("calls.luau");
} }
TEST_CASE("Attrib") TEST_CASE("Attrib")
{ {
runConformance("attrib.lua"); runConformance("attrib.luau");
} }
TEST_CASE("GC") TEST_CASE("GC")
{ {
runConformance("gc.lua"); runConformance("gc.luau");
} }
TEST_CASE("Bitwise") TEST_CASE("Bitwise")
{ {
runConformance("bitwise.lua"); runConformance("bitwise.luau");
} }
TEST_CASE("UTF8") TEST_CASE("UTF8")
{ {
runConformance("utf8.lua"); runConformance("utf8.luau");
} }
TEST_CASE("Coroutine") TEST_CASE("Coroutine")
{ {
runConformance("coroutine.lua"); runConformance("coroutine.luau");
} }
static int cxxthrow(lua_State* L) static int cxxthrow(lua_State* L)
@ -810,7 +810,7 @@ TEST_CASE("PCall")
ScopedFastFlag LuauStackLimit{DFFlag::LuauStackLimit, true}; ScopedFastFlag LuauStackLimit{DFFlag::LuauStackLimit, true};
runConformance( runConformance(
"pcall.lua", "pcall.luau",
[](lua_State* L) [](lua_State* L)
{ {
lua_pushcfunction(L, cxxthrow, "cxxthrow"); lua_pushcfunction(L, cxxthrow, "cxxthrow");
@ -836,7 +836,7 @@ TEST_CASE("PCall")
TEST_CASE("Pack") TEST_CASE("Pack")
{ {
runConformance("tpack.lua"); runConformance("tpack.luau");
} }
TEST_CASE("Vector") TEST_CASE("Vector")
@ -881,7 +881,7 @@ TEST_CASE("Vector")
} }
runConformance( runConformance(
"vector.lua", "vector.luau",
[](lua_State* L) [](lua_State* L)
{ {
setupVectorHelpers(L); setupVectorHelpers(L);
@ -915,7 +915,7 @@ TEST_CASE("VectorLibrary")
copts.optimizationLevel = 2; copts.optimizationLevel = 2;
} }
runConformance("vector_library.lua", [](lua_State* L) {}, nullptr, nullptr, &copts); runConformance("vector_library.luau", [](lua_State* L) {}, nullptr, nullptr, &copts);
} }
static void populateRTTI(lua_State* L, Luau::TypeId type) static void populateRTTI(lua_State* L, Luau::TypeId type)
@ -993,7 +993,7 @@ TEST_CASE("Types")
ScopedFastFlag luauMathLerp{FFlag::LuauMathLerp, true}; ScopedFastFlag luauMathLerp{FFlag::LuauMathLerp, true};
runConformance( runConformance(
"types.lua", "types.luau",
[](lua_State* L) [](lua_State* L)
{ {
Luau::NullModuleResolver moduleResolver; Luau::NullModuleResolver moduleResolver;
@ -1018,12 +1018,12 @@ TEST_CASE("Types")
TEST_CASE("DateTime") TEST_CASE("DateTime")
{ {
runConformance("datetime.lua"); runConformance("datetime.luau");
} }
TEST_CASE("Debug") TEST_CASE("Debug")
{ {
runConformance("debug.lua"); runConformance("debug.luau");
} }
TEST_CASE("Debugger") TEST_CASE("Debugger")
@ -1050,7 +1050,7 @@ TEST_CASE("Debugger")
copts.debugLevel = 2; copts.debugLevel = 2;
runConformance( runConformance(
"debugger.lua", "debugger.luau",
[](lua_State* L) [](lua_State* L)
{ {
lua_Callbacks* cb = lua_callbacks(L); lua_Callbacks* cb = lua_callbacks(L);
@ -1225,7 +1225,7 @@ TEST_CASE("NDebugGetUpValue")
copts.optimizationLevel = 0; copts.optimizationLevel = 0;
runConformance( runConformance(
"ndebug_upvalues.lua", "ndebug_upvalues.luau",
nullptr, nullptr,
[](lua_State* L) [](lua_State* L)
{ {
@ -1456,7 +1456,7 @@ TEST_CASE("ApiIter")
TEST_CASE("ApiCalls") TEST_CASE("ApiCalls")
{ {
StateRef globalState = runConformance("apicalls.lua", nullptr, nullptr, lua_newstate(limitedRealloc, nullptr)); StateRef globalState = runConformance("apicalls.luau", nullptr, nullptr, lua_newstate(limitedRealloc, nullptr));
lua_State* L = globalState.get(); lua_State* L = globalState.get();
// lua_call // lua_call
@ -1783,7 +1783,7 @@ TEST_CASE("ExceptionObject")
return ExceptionResult{false, ""}; return ExceptionResult{false, ""};
}; };
StateRef globalState = runConformance("exceptions.lua", nullptr, nullptr, lua_newstate(limitedRealloc, nullptr)); StateRef globalState = runConformance("exceptions.luau", nullptr, nullptr, lua_newstate(limitedRealloc, nullptr));
lua_State* L = globalState.get(); lua_State* L = globalState.get();
{ {
@ -1822,7 +1822,7 @@ TEST_CASE("ExceptionObject")
TEST_CASE("IfElseExpression") TEST_CASE("IfElseExpression")
{ {
runConformance("ifelseexpr.lua"); runConformance("ifelseexpr.luau");
} }
// Optionally returns debug info for the first Luau stack frame that is encountered on the callstack. // Optionally returns debug info for the first Luau stack frame that is encountered on the callstack.
@ -1860,7 +1860,7 @@ TEST_CASE("TagMethodError")
auto yieldCallback = [](lua_State* L) {}; auto yieldCallback = [](lua_State* L) {};
runConformance( runConformance(
"tmerror.lua", "tmerror.luau",
[](lua_State* L) [](lua_State* L)
{ {
auto* cb = lua_callbacks(L); auto* cb = lua_callbacks(L);
@ -1898,7 +1898,7 @@ TEST_CASE("Coverage")
copts.coverageLevel = 2; copts.coverageLevel = 2;
runConformance( runConformance(
"coverage.lua", "coverage.luau",
[](lua_State* L) [](lua_State* L)
{ {
lua_pushcfunction( lua_pushcfunction(
@ -1952,7 +1952,7 @@ TEST_CASE("Coverage")
TEST_CASE("StringConversion") TEST_CASE("StringConversion")
{ {
runConformance("strconv.lua"); runConformance("strconv.luau");
} }
TEST_CASE("GCDump") TEST_CASE("GCDump")
@ -2065,7 +2065,7 @@ TEST_CASE("Interrupt")
static int index; static int index;
StateRef globalState = runConformance("interrupt.lua", nullptr, nullptr, nullptr, &copts); StateRef globalState = runConformance("interrupt.luau", nullptr, nullptr, nullptr, &copts);
lua_State* L = globalState.get(); lua_State* L = globalState.get();
@ -2366,7 +2366,7 @@ TEST_CASE("DebugApi")
TEST_CASE("Iter") TEST_CASE("Iter")
{ {
runConformance("iter.lua"); runConformance("iter.luau");
} }
const int kInt64Tag = 1; const int kInt64Tag = 1;
@ -2395,7 +2395,7 @@ static void pushInt64(lua_State* L, int64_t value)
TEST_CASE("Userdata") TEST_CASE("Userdata")
{ {
runConformance( runConformance(
"userdata.lua", "userdata.luau",
[](lua_State* L) [](lua_State* L)
{ {
// create metatable with all the metamethods // create metatable with all the metamethods
@ -2617,7 +2617,7 @@ TEST_CASE("Userdata")
TEST_CASE("SafeEnv") TEST_CASE("SafeEnv")
{ {
runConformance("safeenv.lua"); runConformance("safeenv.luau");
} }
TEST_CASE("Native") TEST_CASE("Native")
@ -2639,7 +2639,7 @@ TEST_CASE("Native")
} }
runConformance( runConformance(
"native.lua", "native.luau",
[](lua_State* L) [](lua_State* L)
{ {
setupNativeHelpers(L); setupNativeHelpers(L);
@ -2654,7 +2654,7 @@ TEST_CASE("NativeTypeAnnotations")
return; return;
runConformance( runConformance(
"native_types.lua", "native_types.luau",
[](lua_State* L) [](lua_State* L)
{ {
setupNativeHelpers(L); setupNativeHelpers(L);
@ -2717,7 +2717,7 @@ TEST_CASE("NativeUserdata")
} }
runConformance( runConformance(
"native_userdata.lua", "native_userdata.luau",
[](lua_State* L) [](lua_State* L)
{ {
Luau::CodeGen::setUserdataRemapper( Luau::CodeGen::setUserdataRemapper(

View file

@ -36,7 +36,7 @@ assert(foo(1, 2, 3) == 2)
assert(concat(pcall(function () end)) == "true") assert(concat(pcall(function () end)) == "true")
assert(concat(pcall(function () return nil end)) == "true,nil") assert(concat(pcall(function () return nil end)) == "true,nil")
assert(concat(pcall(function () return 1,2,3 end)) == "true,1,2,3") assert(concat(pcall(function () return 1,2,3 end)) == "true,1,2,3")
assert(concat(pcall(function () error("oops") end)) == "false,basic.lua:39: oops") assert(concat(pcall(function () error("oops") end)) == "false,basic.luau:39: oops")
-- assignments -- assignments
assert((function() local a = 1 a = 2 return a end)() == 2) assert((function() local a = 1 a = 2 return a end)() == 2)

View file

@ -284,7 +284,7 @@ function foo ()
error("foo") error("foo")
end end
local fooerr = "closure.lua:284: foo" local fooerr = "closure.luau:284: foo"
function goo() foo() end function goo() foo() end
x = coroutine.wrap(goo) x = coroutine.wrap(goo)

View file

@ -35,7 +35,7 @@ end
local co2 = coroutine.create(halp) local co2 = coroutine.create(halp)
coroutine.resume(co2, 0 / 0, 42) coroutine.resume(co2, 0 / 0, 42)
assert(debug.traceback(co2) == "debug.lua:31 function halp\n") assert(debug.traceback(co2) == "debug.luau:31 function halp\n")
assert(debug.info(co2, 0, "l") == 31) assert(debug.info(co2, 0, "l") == 31)
assert(debug.info(co2, 0, "f") == halp) assert(debug.info(co2, 0, "f") == halp)
@ -64,7 +64,7 @@ assert(baz(1, "n") == "baz")
assert(baz(2, "n") == "") -- main/anonymous assert(baz(2, "n") == "") -- main/anonymous
assert(baz(3, "n") == nil) assert(baz(3, "n") == nil)
assert(baz(0, "s") == "[C]") assert(baz(0, "s") == "[C]")
assert(baz(1, "s") == "debug.lua") assert(baz(1, "s") == "debug.luau")
assert(baz(0, "l") == -1) assert(baz(0, "l") == -1)
assert(baz(1, "l") > 42) assert(baz(1, "l") > 42)
assert(baz(0, "f") == debug.info) assert(baz(0, "f") == debug.info)
@ -87,7 +87,7 @@ end
assert(#(quux(1, "nlsf")) == 4) assert(#(quux(1, "nlsf")) == 4)
assert(quux(1, "nlsf")[1] == "quux") assert(quux(1, "nlsf")[1] == "quux")
assert(quux(1, "nlsf")[2] > 64) assert(quux(1, "nlsf")[2] > 64)
assert(quux(1, "nlsf")[3] == "debug.lua") assert(quux(1, "nlsf")[3] == "debug.luau")
assert(quux(1, "nlsf")[4] == quux) assert(quux(1, "nlsf")[4] == quux)
-- info arity -- info arity

View file

@ -77,9 +77,9 @@ checkresults({ "yield", "return", true, 1, 2, 3}, colog(function() return pcall(
checkresults({ "yield", 1, "yield", 2, "return", true, true, 3}, colog(function() return pcall(function() coroutine.yield(1) return pcall(function() coroutine.yield(2) return 3 end) end) end)) checkresults({ "yield", 1, "yield", 2, "return", true, true, 3}, colog(function() return pcall(function() coroutine.yield(1) return pcall(function() coroutine.yield(2) return 3 end) end) end))
-- error after yield tests -- error after yield tests
checkresults({ "yield", "return", false, "pcall.lua:80: foo" }, colog(function() return pcall(function() coroutine.yield() error("foo") end) end)) checkresults({ "yield", "return", false, "pcall.luau:80: foo" }, colog(function() return pcall(function() coroutine.yield() error("foo") end) end))
checkresults({ "yield", "yield", "return", true, false, "pcall.lua:81: foo" }, colog(function() return pcall(function() coroutine.yield() return pcall(function() coroutine.yield() error("foo") end) end) end)) checkresults({ "yield", "yield", "return", true, false, "pcall.luau:81: foo" }, colog(function() return pcall(function() coroutine.yield() return pcall(function() coroutine.yield() error("foo") end) end) end))
checkresults({ "yield", "yield", "return", false, "pcall.lua:82: bar" }, colog(function() return pcall(function() coroutine.yield() pcall(function() coroutine.yield() error("foo") end) error("bar") end) end)) checkresults({ "yield", "yield", "return", false, "pcall.luau:82: bar" }, colog(function() return pcall(function() coroutine.yield() pcall(function() coroutine.yield() error("foo") end) error("bar") end) end))
-- returning lots of results (past MINSTACK limits) -- returning lots of results (past MINSTACK limits)
local res = {pcall(function() return table.unpack(table.create(100, 'a')) end)} local res = {pcall(function() return table.unpack(table.create(100, 'a')) end)}
@ -100,15 +100,15 @@ checkresults({ true, 2 }, xpcall(function(...) return select('#', ...) end, erro
checkresults({ "yield", "return", true, 42 }, colog(function() return xpcall(function() coroutine.yield() return 42 end, error) end)) checkresults({ "yield", "return", true, 42 }, colog(function() return xpcall(function() coroutine.yield() return 42 end, error) end))
-- xpcall immediate error handling -- xpcall immediate error handling
checkresults({ false, "pcall.lua:103: foo" }, xpcall(function() error("foo") end, function(err) return err end)) checkresults({ false, "pcall.luau:103: foo" }, xpcall(function() error("foo") end, function(err) return err end))
checkresults({ false, "bar" }, xpcall(function() error("foo") end, function(err) return "bar" end)) checkresults({ false, "bar" }, xpcall(function() error("foo") end, function(err) return "bar" end))
checkresults({ false, 1 }, xpcall(function() error("foo") end, function(err) return 1, 2 end)) checkresults({ false, 1 }, xpcall(function() error("foo") end, function(err) return 1, 2 end))
checkresults({ false, "pcall.lua:106: foo\npcall.lua:106\npcall.lua:106\n" }, xpcall(function() error("foo") end, debug.traceback)) checkresults({ false, "pcall.luau:106: foo\npcall.luau:106\npcall.luau:106\n" }, xpcall(function() error("foo") end, debug.traceback))
checkresults({ false, "error in error handling" }, xpcall(function() error("foo") end, function(err) error("bar") end)) checkresults({ false, "error in error handling" }, xpcall(function() error("foo") end, function(err) error("bar") end))
-- xpcall error handling after yields -- xpcall error handling after yields
checkresults({ "yield", "return", false, "pcall.lua:110: foo" }, colog(function() return xpcall(function() coroutine.yield() error("foo") end, function(err) return err end) end)) checkresults({ "yield", "return", false, "pcall.luau:110: foo" }, colog(function() return xpcall(function() coroutine.yield() error("foo") end, function(err) return err end) end))
checkresults({ "yield", "return", false, "pcall.lua:111: foo\npcall.lua:111\npcall.lua:111\n" }, colog(function() return xpcall(function() coroutine.yield() error("foo") end, debug.traceback) end)) checkresults({ "yield", "return", false, "pcall.luau:111: foo\npcall.luau:111\npcall.luau:111\n" }, colog(function() return xpcall(function() coroutine.yield() error("foo") end, debug.traceback) end))
-- xpcall error handling during error handling inside xpcall after yields -- xpcall error handling during error handling inside xpcall after yields
checkresults({ "yield", "return", true, false, "error in error handling" }, colog(function() return xpcall(function() return xpcall(function() coroutine.yield() error("foo") end, function(err) error("bar") end) end, error) end)) checkresults({ "yield", "return", true, false, "error in error handling" }, colog(function() return xpcall(function() return xpcall(function() coroutine.yield() error("foo") end, function(err) error("bar") end) end, error) end))
@ -126,7 +126,7 @@ coroutine.yield(weird)
weird() weird()
end end
checkresults({ false, "pcall.lua:129: cannot resume dead coroutine" }, pcall(function() for _ in coroutine.wrap(pcall), weird do end end)) checkresults({ false, "pcall.luau:129: cannot resume dead coroutine" }, pcall(function() for _ in coroutine.wrap(pcall), weird do end end))
-- c++ exception -- c++ exception
checkresults({ false, "oops" }, pcall(cxxthrow)) checkresults({ false, "oops" }, pcall(cxxthrow))