luau/tests/Simplify.test.cpp

540 lines
17 KiB
C++
Raw Normal View History

Sync to upstream/release/577 (#934) Lots of things going on this week: * Fix a crash that could occur in the presence of a cyclic union. We shouldn't be creating cyclic unions, but we shouldn't be crashing when they arise either. * Minor cleanup of `luau_precall` * Internal change to make L->top handling slightly more uniform * Optimize SETGLOBAL & GETGLOBAL fallback C functions. * https://github.com/Roblox/luau/pull/929 * The syntax to the `luau-reduce` commandline tool has changed. It now accepts a script, a command to execute, and an error to search for. It no longer automatically passes the script to the command which makes it a lot more flexible. Also be warned that it edits the script it is passed **in place**. Do not point it at something that is not in source control! New solver * Switch to a greedier but more fallible algorithm for simplifying union and intersection types that are created as part of refinement calculation. This has much better and more predictable performance. * Fix a constraint cycle in recursive function calls. * Much improved inference of binary addition. Functions like `function add(x, y) return x + y end` can now be inferred without annotations. We also accurately typecheck calls to functions like this. * Many small bugfixes surrounding things like table indexers * Add support for indexers on class types. This was previously added to the old solver; we now add it to the new one for feature parity. JIT * https://github.com/Roblox/luau/pull/931 * Fuse key.value and key.tt loads for CEHCK_SLOT_MATCH in A64 * Implement remaining aliases of BFM for A64 * Implement new callinfo flag for A64 * Add instruction simplification for int->num->int conversion chains * Don't even load execdata for X64 calls * Treat opcode fallbacks the same as manually written fallbacks --------- Co-authored-by: Arseny Kapoulkine <arseny.kapoulkine@gmail.com> Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>
2023-05-20 03:37:30 +08:00
// This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
#include "Fixture.h"
#include "doctest.h"
#include "Luau/Simplify.h"
using namespace Luau;
Sync to upstream/release/605 (#1118) - Implemented [Require by String with Relative Paths](https://github.com/luau-lang/rfcs/blob/master/docs/new-require-by-string-semantics.md) RFC - Implemented [Require by String with Aliases](https://github.com/luau-lang/rfcs/blob/master/docs/require-by-string-aliases.md) RFC with support for `paths` and `alias` arrays in .luarc - Added SUBRK and DIVRK bytecode instructions to speed up constant-number and constant/number operations - Added `--vector-lib`, `--vector-ctor` and `--vector-type` options to luau-compile to support code with vectors New Solver - Correctness fixes to subtyping - Improvements to dataflow analysis Native Code Generation - Added bytecode analysis pass to predict type tags used in operations - Fixed rare cases of numerical loops being generated without an interrupt instruction - Restored optimization data propagation into the linear block - Duplicate buffer length checks are optimized away Miscellaneous - Small performance improvements to new non-strict mode - Introduced more scripts for fuzzing Luau and processing the results, including fuzzer build support for CMake Co-authored-by: Alexander McCord <amccord@roblox.com> Co-authored-by: Andy Friesen <afriesen@roblox.com> Co-authored-by: Aviral Goel <agoel@roblox.com> Co-authored-by: David Cope <dcope@roblox.com> Co-authored-by: Lily Brown <lbrown@roblox.com> Co-authored-by: Vighnesh Vijay <vvijay@roblox.com> Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com> --------- Co-authored-by: Aaron Weiss <aaronweiss@roblox.com> Co-authored-by: Alexander McCord <amccord@roblox.com> Co-authored-by: Andy Friesen <afriesen@roblox.com> Co-authored-by: Aviral Goel <agoel@roblox.com> Co-authored-by: David Cope <dcope@roblox.com> Co-authored-by: Lily Brown <lbrown@roblox.com> Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>
2023-12-02 15:46:57 +08:00
LUAU_FASTFLAG(DebugLuauDeferredConstraintResolution)
Sync to upstream/release/577 (#934) Lots of things going on this week: * Fix a crash that could occur in the presence of a cyclic union. We shouldn't be creating cyclic unions, but we shouldn't be crashing when they arise either. * Minor cleanup of `luau_precall` * Internal change to make L->top handling slightly more uniform * Optimize SETGLOBAL & GETGLOBAL fallback C functions. * https://github.com/Roblox/luau/pull/929 * The syntax to the `luau-reduce` commandline tool has changed. It now accepts a script, a command to execute, and an error to search for. It no longer automatically passes the script to the command which makes it a lot more flexible. Also be warned that it edits the script it is passed **in place**. Do not point it at something that is not in source control! New solver * Switch to a greedier but more fallible algorithm for simplifying union and intersection types that are created as part of refinement calculation. This has much better and more predictable performance. * Fix a constraint cycle in recursive function calls. * Much improved inference of binary addition. Functions like `function add(x, y) return x + y end` can now be inferred without annotations. We also accurately typecheck calls to functions like this. * Many small bugfixes surrounding things like table indexers * Add support for indexers on class types. This was previously added to the old solver; we now add it to the new one for feature parity. JIT * https://github.com/Roblox/luau/pull/931 * Fuse key.value and key.tt loads for CEHCK_SLOT_MATCH in A64 * Implement remaining aliases of BFM for A64 * Implement new callinfo flag for A64 * Add instruction simplification for int->num->int conversion chains * Don't even load execdata for X64 calls * Treat opcode fallbacks the same as manually written fallbacks --------- Co-authored-by: Arseny Kapoulkine <arseny.kapoulkine@gmail.com> Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>
2023-05-20 03:37:30 +08:00
namespace
{
struct SimplifyFixture : Fixture
{
TypeArena _arena;
const NotNull<TypeArena> arena{&_arena};
ToStringOptions opts;
Scope scope{builtinTypes->anyTypePack};
const TypeId anyTy = builtinTypes->anyType;
const TypeId unknownTy = builtinTypes->unknownType;
const TypeId neverTy = builtinTypes->neverType;
const TypeId errorTy = builtinTypes->errorType;
const TypeId functionTy = builtinTypes->functionType;
const TypeId tableTy = builtinTypes->tableType;
const TypeId numberTy = builtinTypes->numberType;
const TypeId stringTy = builtinTypes->stringType;
const TypeId booleanTy = builtinTypes->booleanType;
const TypeId nilTy = builtinTypes->nilType;
const TypeId classTy = builtinTypes->classType;
const TypeId trueTy = builtinTypes->trueType;
const TypeId falseTy = builtinTypes->falseType;
const TypeId truthyTy = builtinTypes->truthyType;
const TypeId falsyTy = builtinTypes->falsyType;
const TypeId freeTy = freshType(arena, builtinTypes, &scope);
Sync to upstream/release/577 (#934) Lots of things going on this week: * Fix a crash that could occur in the presence of a cyclic union. We shouldn't be creating cyclic unions, but we shouldn't be crashing when they arise either. * Minor cleanup of `luau_precall` * Internal change to make L->top handling slightly more uniform * Optimize SETGLOBAL & GETGLOBAL fallback C functions. * https://github.com/Roblox/luau/pull/929 * The syntax to the `luau-reduce` commandline tool has changed. It now accepts a script, a command to execute, and an error to search for. It no longer automatically passes the script to the command which makes it a lot more flexible. Also be warned that it edits the script it is passed **in place**. Do not point it at something that is not in source control! New solver * Switch to a greedier but more fallible algorithm for simplifying union and intersection types that are created as part of refinement calculation. This has much better and more predictable performance. * Fix a constraint cycle in recursive function calls. * Much improved inference of binary addition. Functions like `function add(x, y) return x + y end` can now be inferred without annotations. We also accurately typecheck calls to functions like this. * Many small bugfixes surrounding things like table indexers * Add support for indexers on class types. This was previously added to the old solver; we now add it to the new one for feature parity. JIT * https://github.com/Roblox/luau/pull/931 * Fuse key.value and key.tt loads for CEHCK_SLOT_MATCH in A64 * Implement remaining aliases of BFM for A64 * Implement new callinfo flag for A64 * Add instruction simplification for int->num->int conversion chains * Don't even load execdata for X64 calls * Treat opcode fallbacks the same as manually written fallbacks --------- Co-authored-by: Arseny Kapoulkine <arseny.kapoulkine@gmail.com> Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>
2023-05-20 03:37:30 +08:00
const TypeId genericTy = arena->addType(GenericType{});
const TypeId blockedTy = arena->addType(BlockedType{});
const TypeId pendingTy = arena->addType(PendingExpansionType{{}, {}, {}, {}});
const TypeId helloTy = arena->addType(SingletonType{StringSingleton{"hello"}});
const TypeId worldTy = arena->addType(SingletonType{StringSingleton{"world"}});
const TypePackId emptyTypePack = arena->addTypePack({});
const TypeId fn1Ty = arena->addType(FunctionType{emptyTypePack, emptyTypePack});
const TypeId fn2Ty = arena->addType(FunctionType{builtinTypes->anyTypePack, emptyTypePack});
TypeId parentClassTy = nullptr;
TypeId childClassTy = nullptr;
TypeId anotherChildClassTy = nullptr;
TypeId unrelatedClassTy = nullptr;
Sync to upstream/release/605 (#1118) - Implemented [Require by String with Relative Paths](https://github.com/luau-lang/rfcs/blob/master/docs/new-require-by-string-semantics.md) RFC - Implemented [Require by String with Aliases](https://github.com/luau-lang/rfcs/blob/master/docs/require-by-string-aliases.md) RFC with support for `paths` and `alias` arrays in .luarc - Added SUBRK and DIVRK bytecode instructions to speed up constant-number and constant/number operations - Added `--vector-lib`, `--vector-ctor` and `--vector-type` options to luau-compile to support code with vectors New Solver - Correctness fixes to subtyping - Improvements to dataflow analysis Native Code Generation - Added bytecode analysis pass to predict type tags used in operations - Fixed rare cases of numerical loops being generated without an interrupt instruction - Restored optimization data propagation into the linear block - Duplicate buffer length checks are optimized away Miscellaneous - Small performance improvements to new non-strict mode - Introduced more scripts for fuzzing Luau and processing the results, including fuzzer build support for CMake Co-authored-by: Alexander McCord <amccord@roblox.com> Co-authored-by: Andy Friesen <afriesen@roblox.com> Co-authored-by: Aviral Goel <agoel@roblox.com> Co-authored-by: David Cope <dcope@roblox.com> Co-authored-by: Lily Brown <lbrown@roblox.com> Co-authored-by: Vighnesh Vijay <vvijay@roblox.com> Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com> --------- Co-authored-by: Aaron Weiss <aaronweiss@roblox.com> Co-authored-by: Alexander McCord <amccord@roblox.com> Co-authored-by: Andy Friesen <afriesen@roblox.com> Co-authored-by: Aviral Goel <agoel@roblox.com> Co-authored-by: David Cope <dcope@roblox.com> Co-authored-by: Lily Brown <lbrown@roblox.com> Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>
2023-12-02 15:46:57 +08:00
ScopedFastFlag sff{FFlag::DebugLuauDeferredConstraintResolution, true};
Sync to upstream/release/577 (#934) Lots of things going on this week: * Fix a crash that could occur in the presence of a cyclic union. We shouldn't be creating cyclic unions, but we shouldn't be crashing when they arise either. * Minor cleanup of `luau_precall` * Internal change to make L->top handling slightly more uniform * Optimize SETGLOBAL & GETGLOBAL fallback C functions. * https://github.com/Roblox/luau/pull/929 * The syntax to the `luau-reduce` commandline tool has changed. It now accepts a script, a command to execute, and an error to search for. It no longer automatically passes the script to the command which makes it a lot more flexible. Also be warned that it edits the script it is passed **in place**. Do not point it at something that is not in source control! New solver * Switch to a greedier but more fallible algorithm for simplifying union and intersection types that are created as part of refinement calculation. This has much better and more predictable performance. * Fix a constraint cycle in recursive function calls. * Much improved inference of binary addition. Functions like `function add(x, y) return x + y end` can now be inferred without annotations. We also accurately typecheck calls to functions like this. * Many small bugfixes surrounding things like table indexers * Add support for indexers on class types. This was previously added to the old solver; we now add it to the new one for feature parity. JIT * https://github.com/Roblox/luau/pull/931 * Fuse key.value and key.tt loads for CEHCK_SLOT_MATCH in A64 * Implement remaining aliases of BFM for A64 * Implement new callinfo flag for A64 * Add instruction simplification for int->num->int conversion chains * Don't even load execdata for X64 calls * Treat opcode fallbacks the same as manually written fallbacks --------- Co-authored-by: Arseny Kapoulkine <arseny.kapoulkine@gmail.com> Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>
2023-05-20 03:37:30 +08:00
SimplifyFixture()
{
createSomeClasses(&frontend);
parentClassTy = frontend.globals.globalScope->linearSearchForBinding("Parent")->typeId;
childClassTy = frontend.globals.globalScope->linearSearchForBinding("Child")->typeId;
anotherChildClassTy = frontend.globals.globalScope->linearSearchForBinding("AnotherChild")->typeId;
unrelatedClassTy = frontend.globals.globalScope->linearSearchForBinding("Unrelated")->typeId;
}
TypeId intersect(TypeId a, TypeId b)
{
return simplifyIntersection(builtinTypes, arena, a, b).result;
}
std::string intersectStr(TypeId a, TypeId b)
{
return toString(intersect(a, b), opts);
}
bool isIntersection(TypeId a)
{
return bool(get<IntersectionType>(follow(a)));
}
TypeId mkTable(std::map<Name, TypeId> propTypes)
{
TableType::Props props;
for (const auto& [name, ty] : propTypes)
props[name] = Property{ty};
return arena->addType(TableType{props, {}, TypeLevel{}, TableState::Sealed});
}
TypeId mkNegation(TypeId ty)
{
return arena->addType(NegationType{ty});
}
TypeId mkFunction(TypeId arg, TypeId ret)
{
return arena->addType(FunctionType{arena->addTypePack({arg}), arena->addTypePack({ret})});
}
TypeId union_(TypeId a, TypeId b)
{
return simplifyUnion(builtinTypes, arena, a, b).result;
}
};
} // namespace
TEST_SUITE_BEGIN("Simplify");
Sync to upstream/release/588 (#992) Type checker/autocomplete: * `Luau::autocomplete` no longer performs typechecking internally, make sure to run `Frontend::check` before performing autocomplete requests * Autocomplete string suggestions without "" are now only suggested inside the "" * Autocomplete suggestions now include `function (anonymous autofilled)` key with a full suggestion for the function expression (with arguments included) stored in `AutocompleteEntry::insertText` * `AutocompleteEntry::indexedWithSelf` is provided for function call suggestions made with `:` * Cyclic modules now see each other type exports as `any` to prevent memory use-after-free (similar to module return type) Runtime: * Updated inline/loop unroll cost model to better handle assignments (Fixes https://github.com/Roblox/luau/issues/978) * `math.noise` speed was improved by ~30% * `table.concat` speed was improved by ~5-7% * `tonumber` and `tostring` now have fastcall paths that execute ~1.5x and ~2.5x faster respectively (fixes #777) * Fixed crash in `luaL_typename` when index refers to a non-existing value * Fixed potential out of memory scenario when using `string.sub` or `string.char` in a loop * Fixed behavior of some fastcall builtins when called without arguments under -O2 to match original functions * Support for native code execution in VM is now enabled by default (note: native code still has to be generated explicitly) * `Codegen::compile` now accepts `CodeGen_OnlyNativeModules` flag. When set, only modules that have a `--!native` hot-comment at the top will be compiled to native code In our new typechecker: * Generic type packs are no longer considered to be variadic during unification * Timeout and cancellation now works in new solver * Fixed false positive errors around 'table' and 'function' type refinements * Table literals now use covariant unification rules. This is sound since literal has no type specified and has no aliases * Fixed issues with blocked types escaping the constraint solver * Fixed more places where error messages that should've been suppressed were still reported * Fixed errors when iterating over a top table type In our native code generation (jit): * 'DebugLuauAbortingChecks' flag is now supported on A64 * LOP_NEWCLOSURE has been translated to IR
2023-07-28 23:13:53 +08:00
TEST_CASE_FIXTURE(SimplifyFixture, "overload_negation_refinement_is_never")
{
TypeId f1 = mkFunction(stringTy, numberTy);
TypeId f2 = mkFunction(numberTy, stringTy);
TypeId intersection = arena->addType(IntersectionType{{f1, f2}});
TypeId unionT = arena->addType(UnionType{{errorTy, functionTy}});
TypeId negationT = mkNegation(unionT);
// The intersection of string -> number & number -> string, ~(error | function)
CHECK(neverTy == intersect(intersection, negationT));
}
Sync to upstream/release/577 (#934) Lots of things going on this week: * Fix a crash that could occur in the presence of a cyclic union. We shouldn't be creating cyclic unions, but we shouldn't be crashing when they arise either. * Minor cleanup of `luau_precall` * Internal change to make L->top handling slightly more uniform * Optimize SETGLOBAL & GETGLOBAL fallback C functions. * https://github.com/Roblox/luau/pull/929 * The syntax to the `luau-reduce` commandline tool has changed. It now accepts a script, a command to execute, and an error to search for. It no longer automatically passes the script to the command which makes it a lot more flexible. Also be warned that it edits the script it is passed **in place**. Do not point it at something that is not in source control! New solver * Switch to a greedier but more fallible algorithm for simplifying union and intersection types that are created as part of refinement calculation. This has much better and more predictable performance. * Fix a constraint cycle in recursive function calls. * Much improved inference of binary addition. Functions like `function add(x, y) return x + y end` can now be inferred without annotations. We also accurately typecheck calls to functions like this. * Many small bugfixes surrounding things like table indexers * Add support for indexers on class types. This was previously added to the old solver; we now add it to the new one for feature parity. JIT * https://github.com/Roblox/luau/pull/931 * Fuse key.value and key.tt loads for CEHCK_SLOT_MATCH in A64 * Implement remaining aliases of BFM for A64 * Implement new callinfo flag for A64 * Add instruction simplification for int->num->int conversion chains * Don't even load execdata for X64 calls * Treat opcode fallbacks the same as manually written fallbacks --------- Co-authored-by: Arseny Kapoulkine <arseny.kapoulkine@gmail.com> Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>
2023-05-20 03:37:30 +08:00
TEST_CASE_FIXTURE(SimplifyFixture, "unknown_and_other_tops_and_bottom_types")
{
CHECK(unknownTy == intersect(unknownTy, unknownTy));
CHECK(unknownTy == intersect(unknownTy, anyTy));
CHECK(unknownTy == intersect(anyTy, unknownTy));
CHECK(neverTy == intersect(unknownTy, neverTy));
CHECK(neverTy == intersect(neverTy, unknownTy));
CHECK(neverTy == intersect(unknownTy, errorTy));
CHECK(neverTy == intersect(errorTy, unknownTy));
}
TEST_CASE_FIXTURE(SimplifyFixture, "nil")
{
CHECK(nilTy == intersect(nilTy, nilTy));
CHECK(neverTy == intersect(nilTy, numberTy));
CHECK(neverTy == intersect(nilTy, trueTy));
CHECK(neverTy == intersect(nilTy, tableTy));
}
TEST_CASE_FIXTURE(SimplifyFixture, "boolean_singletons")
{
CHECK(trueTy == intersect(trueTy, booleanTy));
CHECK(trueTy == intersect(booleanTy, trueTy));
CHECK(falseTy == intersect(falseTy, booleanTy));
CHECK(falseTy == intersect(booleanTy, falseTy));
CHECK(neverTy == intersect(falseTy, trueTy));
CHECK(neverTy == intersect(trueTy, falseTy));
CHECK(booleanTy == union_(trueTy, booleanTy));
CHECK(booleanTy == union_(booleanTy, trueTy));
CHECK(booleanTy == union_(falseTy, booleanTy));
CHECK(booleanTy == union_(booleanTy, falseTy));
CHECK(booleanTy == union_(falseTy, trueTy));
}
TEST_CASE_FIXTURE(SimplifyFixture, "boolean_and_truthy_and_falsy")
{
TypeId optionalBooleanTy = arena->addType(UnionType{{booleanTy, nilTy}});
CHECK(trueTy == intersect(booleanTy, truthyTy));
CHECK(trueTy == intersect(optionalBooleanTy, truthyTy));
}
TEST_CASE_FIXTURE(SimplifyFixture, "any_and_indeterminate_types")
{
CHECK("'a" == intersectStr(anyTy, freeTy));
CHECK("'a" == intersectStr(freeTy, anyTy));
Sync to upstream/release/577 (#934) Lots of things going on this week: * Fix a crash that could occur in the presence of a cyclic union. We shouldn't be creating cyclic unions, but we shouldn't be crashing when they arise either. * Minor cleanup of `luau_precall` * Internal change to make L->top handling slightly more uniform * Optimize SETGLOBAL & GETGLOBAL fallback C functions. * https://github.com/Roblox/luau/pull/929 * The syntax to the `luau-reduce` commandline tool has changed. It now accepts a script, a command to execute, and an error to search for. It no longer automatically passes the script to the command which makes it a lot more flexible. Also be warned that it edits the script it is passed **in place**. Do not point it at something that is not in source control! New solver * Switch to a greedier but more fallible algorithm for simplifying union and intersection types that are created as part of refinement calculation. This has much better and more predictable performance. * Fix a constraint cycle in recursive function calls. * Much improved inference of binary addition. Functions like `function add(x, y) return x + y end` can now be inferred without annotations. We also accurately typecheck calls to functions like this. * Many small bugfixes surrounding things like table indexers * Add support for indexers on class types. This was previously added to the old solver; we now add it to the new one for feature parity. JIT * https://github.com/Roblox/luau/pull/931 * Fuse key.value and key.tt loads for CEHCK_SLOT_MATCH in A64 * Implement remaining aliases of BFM for A64 * Implement new callinfo flag for A64 * Add instruction simplification for int->num->int conversion chains * Don't even load execdata for X64 calls * Treat opcode fallbacks the same as manually written fallbacks --------- Co-authored-by: Arseny Kapoulkine <arseny.kapoulkine@gmail.com> Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>
2023-05-20 03:37:30 +08:00
CHECK("b" == intersectStr(anyTy, genericTy));
CHECK("b" == intersectStr(genericTy, anyTy));
CHECK(blockedTy == intersect(anyTy, blockedTy));
CHECK(blockedTy == intersect(blockedTy, anyTy));
CHECK(pendingTy == intersect(anyTy, pendingTy));
CHECK(pendingTy == intersect(pendingTy, anyTy));
}
TEST_CASE_FIXTURE(SimplifyFixture, "unknown_and_indeterminate_types")
{
CHECK(freeTy == intersect(unknownTy, freeTy));
CHECK(freeTy == intersect(freeTy, unknownTy));
TypeId t = nullptr;
Sync to upstream/release/577 (#934) Lots of things going on this week: * Fix a crash that could occur in the presence of a cyclic union. We shouldn't be creating cyclic unions, but we shouldn't be crashing when they arise either. * Minor cleanup of `luau_precall` * Internal change to make L->top handling slightly more uniform * Optimize SETGLOBAL & GETGLOBAL fallback C functions. * https://github.com/Roblox/luau/pull/929 * The syntax to the `luau-reduce` commandline tool has changed. It now accepts a script, a command to execute, and an error to search for. It no longer automatically passes the script to the command which makes it a lot more flexible. Also be warned that it edits the script it is passed **in place**. Do not point it at something that is not in source control! New solver * Switch to a greedier but more fallible algorithm for simplifying union and intersection types that are created as part of refinement calculation. This has much better and more predictable performance. * Fix a constraint cycle in recursive function calls. * Much improved inference of binary addition. Functions like `function add(x, y) return x + y end` can now be inferred without annotations. We also accurately typecheck calls to functions like this. * Many small bugfixes surrounding things like table indexers * Add support for indexers on class types. This was previously added to the old solver; we now add it to the new one for feature parity. JIT * https://github.com/Roblox/luau/pull/931 * Fuse key.value and key.tt loads for CEHCK_SLOT_MATCH in A64 * Implement remaining aliases of BFM for A64 * Implement new callinfo flag for A64 * Add instruction simplification for int->num->int conversion chains * Don't even load execdata for X64 calls * Treat opcode fallbacks the same as manually written fallbacks --------- Co-authored-by: Arseny Kapoulkine <arseny.kapoulkine@gmail.com> Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>
2023-05-20 03:37:30 +08:00
t = intersect(unknownTy, genericTy);
CHECK_MESSAGE(isIntersection(t), "Should be an intersection but got " << t);
t = intersect(genericTy, unknownTy);
CHECK_MESSAGE(isIntersection(t), "Should be an intersection but got " << t);
Sync to upstream/release/577 (#934) Lots of things going on this week: * Fix a crash that could occur in the presence of a cyclic union. We shouldn't be creating cyclic unions, but we shouldn't be crashing when they arise either. * Minor cleanup of `luau_precall` * Internal change to make L->top handling slightly more uniform * Optimize SETGLOBAL & GETGLOBAL fallback C functions. * https://github.com/Roblox/luau/pull/929 * The syntax to the `luau-reduce` commandline tool has changed. It now accepts a script, a command to execute, and an error to search for. It no longer automatically passes the script to the command which makes it a lot more flexible. Also be warned that it edits the script it is passed **in place**. Do not point it at something that is not in source control! New solver * Switch to a greedier but more fallible algorithm for simplifying union and intersection types that are created as part of refinement calculation. This has much better and more predictable performance. * Fix a constraint cycle in recursive function calls. * Much improved inference of binary addition. Functions like `function add(x, y) return x + y end` can now be inferred without annotations. We also accurately typecheck calls to functions like this. * Many small bugfixes surrounding things like table indexers * Add support for indexers on class types. This was previously added to the old solver; we now add it to the new one for feature parity. JIT * https://github.com/Roblox/luau/pull/931 * Fuse key.value and key.tt loads for CEHCK_SLOT_MATCH in A64 * Implement remaining aliases of BFM for A64 * Implement new callinfo flag for A64 * Add instruction simplification for int->num->int conversion chains * Don't even load execdata for X64 calls * Treat opcode fallbacks the same as manually written fallbacks --------- Co-authored-by: Arseny Kapoulkine <arseny.kapoulkine@gmail.com> Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>
2023-05-20 03:37:30 +08:00
t = intersect(unknownTy, blockedTy);
CHECK_MESSAGE(isIntersection(t), "Should be an intersection but got " << t);
t = intersect(blockedTy, unknownTy);
CHECK_MESSAGE(isIntersection(t), "Should be an intersection but got " << t);
Sync to upstream/release/577 (#934) Lots of things going on this week: * Fix a crash that could occur in the presence of a cyclic union. We shouldn't be creating cyclic unions, but we shouldn't be crashing when they arise either. * Minor cleanup of `luau_precall` * Internal change to make L->top handling slightly more uniform * Optimize SETGLOBAL & GETGLOBAL fallback C functions. * https://github.com/Roblox/luau/pull/929 * The syntax to the `luau-reduce` commandline tool has changed. It now accepts a script, a command to execute, and an error to search for. It no longer automatically passes the script to the command which makes it a lot more flexible. Also be warned that it edits the script it is passed **in place**. Do not point it at something that is not in source control! New solver * Switch to a greedier but more fallible algorithm for simplifying union and intersection types that are created as part of refinement calculation. This has much better and more predictable performance. * Fix a constraint cycle in recursive function calls. * Much improved inference of binary addition. Functions like `function add(x, y) return x + y end` can now be inferred without annotations. We also accurately typecheck calls to functions like this. * Many small bugfixes surrounding things like table indexers * Add support for indexers on class types. This was previously added to the old solver; we now add it to the new one for feature parity. JIT * https://github.com/Roblox/luau/pull/931 * Fuse key.value and key.tt loads for CEHCK_SLOT_MATCH in A64 * Implement remaining aliases of BFM for A64 * Implement new callinfo flag for A64 * Add instruction simplification for int->num->int conversion chains * Don't even load execdata for X64 calls * Treat opcode fallbacks the same as manually written fallbacks --------- Co-authored-by: Arseny Kapoulkine <arseny.kapoulkine@gmail.com> Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>
2023-05-20 03:37:30 +08:00
t = intersect(unknownTy, pendingTy);
CHECK_MESSAGE(isIntersection(t), "Should be an intersection but got " << t);
t = intersect(pendingTy, unknownTy);
CHECK_MESSAGE(isIntersection(t), "Should be an intersection but got " << t);
Sync to upstream/release/577 (#934) Lots of things going on this week: * Fix a crash that could occur in the presence of a cyclic union. We shouldn't be creating cyclic unions, but we shouldn't be crashing when they arise either. * Minor cleanup of `luau_precall` * Internal change to make L->top handling slightly more uniform * Optimize SETGLOBAL & GETGLOBAL fallback C functions. * https://github.com/Roblox/luau/pull/929 * The syntax to the `luau-reduce` commandline tool has changed. It now accepts a script, a command to execute, and an error to search for. It no longer automatically passes the script to the command which makes it a lot more flexible. Also be warned that it edits the script it is passed **in place**. Do not point it at something that is not in source control! New solver * Switch to a greedier but more fallible algorithm for simplifying union and intersection types that are created as part of refinement calculation. This has much better and more predictable performance. * Fix a constraint cycle in recursive function calls. * Much improved inference of binary addition. Functions like `function add(x, y) return x + y end` can now be inferred without annotations. We also accurately typecheck calls to functions like this. * Many small bugfixes surrounding things like table indexers * Add support for indexers on class types. This was previously added to the old solver; we now add it to the new one for feature parity. JIT * https://github.com/Roblox/luau/pull/931 * Fuse key.value and key.tt loads for CEHCK_SLOT_MATCH in A64 * Implement remaining aliases of BFM for A64 * Implement new callinfo flag for A64 * Add instruction simplification for int->num->int conversion chains * Don't even load execdata for X64 calls * Treat opcode fallbacks the same as manually written fallbacks --------- Co-authored-by: Arseny Kapoulkine <arseny.kapoulkine@gmail.com> Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>
2023-05-20 03:37:30 +08:00
}
TEST_CASE_FIXTURE(SimplifyFixture, "unknown_and_concrete")
{
CHECK(numberTy == intersect(numberTy, unknownTy));
CHECK(numberTy == intersect(unknownTy, numberTy));
CHECK(trueTy == intersect(trueTy, unknownTy));
CHECK(trueTy == intersect(unknownTy, trueTy));
}
TEST_CASE_FIXTURE(SimplifyFixture, "error_and_other_tops_and_bottom_types")
{
CHECK(errorTy == intersect(errorTy, errorTy));
CHECK(errorTy == intersect(errorTy, anyTy));
CHECK(errorTy == intersect(anyTy, errorTy));
CHECK(neverTy == intersect(errorTy, neverTy));
CHECK(neverTy == intersect(neverTy, errorTy));
}
TEST_CASE_FIXTURE(SimplifyFixture, "error_and_indeterminate_types")
{
CHECK("'a & *error-type*" == intersectStr(errorTy, freeTy));
CHECK("'a & *error-type*" == intersectStr(freeTy, errorTy));
Sync to upstream/release/577 (#934) Lots of things going on this week: * Fix a crash that could occur in the presence of a cyclic union. We shouldn't be creating cyclic unions, but we shouldn't be crashing when they arise either. * Minor cleanup of `luau_precall` * Internal change to make L->top handling slightly more uniform * Optimize SETGLOBAL & GETGLOBAL fallback C functions. * https://github.com/Roblox/luau/pull/929 * The syntax to the `luau-reduce` commandline tool has changed. It now accepts a script, a command to execute, and an error to search for. It no longer automatically passes the script to the command which makes it a lot more flexible. Also be warned that it edits the script it is passed **in place**. Do not point it at something that is not in source control! New solver * Switch to a greedier but more fallible algorithm for simplifying union and intersection types that are created as part of refinement calculation. This has much better and more predictable performance. * Fix a constraint cycle in recursive function calls. * Much improved inference of binary addition. Functions like `function add(x, y) return x + y end` can now be inferred without annotations. We also accurately typecheck calls to functions like this. * Many small bugfixes surrounding things like table indexers * Add support for indexers on class types. This was previously added to the old solver; we now add it to the new one for feature parity. JIT * https://github.com/Roblox/luau/pull/931 * Fuse key.value and key.tt loads for CEHCK_SLOT_MATCH in A64 * Implement remaining aliases of BFM for A64 * Implement new callinfo flag for A64 * Add instruction simplification for int->num->int conversion chains * Don't even load execdata for X64 calls * Treat opcode fallbacks the same as manually written fallbacks --------- Co-authored-by: Arseny Kapoulkine <arseny.kapoulkine@gmail.com> Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>
2023-05-20 03:37:30 +08:00
CHECK("*error-type* & b" == intersectStr(errorTy, genericTy));
CHECK("*error-type* & b" == intersectStr(genericTy, errorTy));
CHECK(isIntersection(intersect(errorTy, blockedTy)));
CHECK(isIntersection(intersect(blockedTy, errorTy)));
CHECK(isIntersection(intersect(errorTy, pendingTy)));
CHECK(isIntersection(intersect(pendingTy, errorTy)));
}
TEST_CASE_FIXTURE(SimplifyFixture, "unknown_and_concrete")
{
CHECK(neverTy == intersect(numberTy, errorTy));
CHECK(neverTy == intersect(errorTy, numberTy));
CHECK(neverTy == intersect(trueTy, errorTy));
CHECK(neverTy == intersect(errorTy, trueTy));
}
TEST_CASE_FIXTURE(SimplifyFixture, "primitives")
{
// This shouldn't be possible, but we'll make it work even if it is.
TypeId numberTyDuplicate = arena->addType(PrimitiveType{PrimitiveType::Number});
CHECK(numberTy == intersect(numberTy, numberTyDuplicate));
CHECK(neverTy == intersect(numberTy, stringTy));
CHECK(neverTy == intersect(neverTy, numberTy));
CHECK(neverTy == intersect(numberTy, neverTy));
CHECK(neverTy == intersect(neverTy, functionTy));
CHECK(neverTy == intersect(functionTy, neverTy));
CHECK(neverTy == intersect(neverTy, tableTy));
CHECK(neverTy == intersect(tableTy, neverTy));
CHECK(numberTy == intersect(anyTy, numberTy));
CHECK(numberTy == intersect(numberTy, anyTy));
CHECK(neverTy == intersect(stringTy, nilTy));
CHECK(neverTy == intersect(nilTy, stringTy));
}
TEST_CASE_FIXTURE(SimplifyFixture, "primitives_and_falsy")
{
CHECK(neverTy == intersect(numberTy, falsyTy));
CHECK(neverTy == intersect(falsyTy, numberTy));
CHECK(nilTy == intersect(nilTy, falsyTy));
CHECK(nilTy == intersect(falsyTy, nilTy));
}
TEST_CASE_FIXTURE(SimplifyFixture, "primitives_and_singletons")
{
CHECK(helloTy == intersect(helloTy, stringTy));
CHECK(helloTy == intersect(stringTy, helloTy));
CHECK(neverTy == intersect(worldTy, helloTy));
}
TEST_CASE_FIXTURE(SimplifyFixture, "functions")
{
CHECK(fn1Ty == intersect(fn1Ty, functionTy));
CHECK(fn1Ty == intersect(functionTy, fn1Ty));
// Intersections of functions are super weird if you think about it.
CHECK("(() -> ()) & ((...any) -> ())" == intersectStr(fn1Ty, fn2Ty));
}
TEST_CASE_FIXTURE(SimplifyFixture, "negated_top_function_type")
{
TypeId negatedFunctionTy = mkNegation(functionTy);
CHECK(numberTy == intersect(numberTy, negatedFunctionTy));
CHECK(numberTy == intersect(negatedFunctionTy, numberTy));
CHECK(falsyTy == intersect(falsyTy, negatedFunctionTy));
CHECK(falsyTy == intersect(negatedFunctionTy, falsyTy));
TypeId f = mkFunction(stringTy, numberTy);
CHECK(neverTy == intersect(f, negatedFunctionTy));
CHECK(neverTy == intersect(negatedFunctionTy, f));
}
TEST_CASE_FIXTURE(SimplifyFixture, "optional_overloaded_function_and_top_function")
{
// (((number) -> string) & ((string) -> number))? & ~function
TypeId f1 = mkFunction(numberTy, stringTy);
TypeId f2 = mkFunction(stringTy, numberTy);
TypeId f12 = arena->addType(IntersectionType{{f1, f2}});
TypeId t = arena->addType(UnionType{{f12, nilTy}});
TypeId notFunctionTy = mkNegation(functionTy);
CHECK(nilTy == intersect(t, notFunctionTy));
CHECK(nilTy == intersect(notFunctionTy, t));
}
TEST_CASE_FIXTURE(SimplifyFixture, "negated_function_does_not_intersect_cleanly_with_truthy")
{
// ~function & ~(false?)
// ~function & ~(false | nil)
// ~function & ~false & ~nil
TypeId negatedFunctionTy = mkNegation(functionTy);
CHECK(isIntersection(intersect(negatedFunctionTy, truthyTy)));
}
TEST_CASE_FIXTURE(SimplifyFixture, "tables")
{
TypeId t1 = mkTable({{"tag", stringTy}});
CHECK(t1 == intersect(t1, tableTy));
CHECK(neverTy == intersect(t1, functionTy));
TypeId t2 = mkTable({{"tag", helloTy}});
CHECK(t2 == intersect(t1, t2));
CHECK(t2 == intersect(t2, t1));
TypeId t3 = mkTable({});
// {tag : string} intersect {{}}
Sync to upstream/release/577 (#934) Lots of things going on this week: * Fix a crash that could occur in the presence of a cyclic union. We shouldn't be creating cyclic unions, but we shouldn't be crashing when they arise either. * Minor cleanup of `luau_precall` * Internal change to make L->top handling slightly more uniform * Optimize SETGLOBAL & GETGLOBAL fallback C functions. * https://github.com/Roblox/luau/pull/929 * The syntax to the `luau-reduce` commandline tool has changed. It now accepts a script, a command to execute, and an error to search for. It no longer automatically passes the script to the command which makes it a lot more flexible. Also be warned that it edits the script it is passed **in place**. Do not point it at something that is not in source control! New solver * Switch to a greedier but more fallible algorithm for simplifying union and intersection types that are created as part of refinement calculation. This has much better and more predictable performance. * Fix a constraint cycle in recursive function calls. * Much improved inference of binary addition. Functions like `function add(x, y) return x + y end` can now be inferred without annotations. We also accurately typecheck calls to functions like this. * Many small bugfixes surrounding things like table indexers * Add support for indexers on class types. This was previously added to the old solver; we now add it to the new one for feature parity. JIT * https://github.com/Roblox/luau/pull/931 * Fuse key.value and key.tt loads for CEHCK_SLOT_MATCH in A64 * Implement remaining aliases of BFM for A64 * Implement new callinfo flag for A64 * Add instruction simplification for int->num->int conversion chains * Don't even load execdata for X64 calls * Treat opcode fallbacks the same as manually written fallbacks --------- Co-authored-by: Arseny Kapoulkine <arseny.kapoulkine@gmail.com> Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>
2023-05-20 03:37:30 +08:00
CHECK(t1 == intersect(t1, t3));
CHECK(t1 == intersect(t3, t1));
}
TEST_CASE_FIXTURE(SimplifyFixture, "tables_and_top_table")
{
TypeId notTableType = mkNegation(tableTy);
TypeId t1 = mkTable({{"prop", stringTy}, {"another", numberTy}});
CHECK(t1 == intersect(t1, tableTy));
CHECK(t1 == intersect(tableTy, t1));
CHECK(neverTy == intersect(t1, notTableType));
CHECK(neverTy == intersect(notTableType, t1));
}
TEST_CASE_FIXTURE(SimplifyFixture, "tables_and_truthy")
{
TypeId t1 = mkTable({{"prop", stringTy}, {"another", numberTy}});
CHECK(t1 == intersect(t1, truthyTy));
CHECK(t1 == intersect(truthyTy, t1));
}
TEST_CASE_FIXTURE(SimplifyFixture, "table_with_a_tag")
{
// {tag: string, prop: number} & {tag: "hello"}
// I think we can decline to simplify this:
TypeId t1 = mkTable({{"tag", stringTy}, {"prop", numberTy}});
TypeId t2 = mkTable({{"tag", helloTy}});
CHECK("{ prop: number, tag: string } & { tag: \"hello\" }" == intersectStr(t1, t2));
CHECK("{ prop: number, tag: string } & { tag: \"hello\" }" == intersectStr(t2, t1));
Sync to upstream/release/577 (#934) Lots of things going on this week: * Fix a crash that could occur in the presence of a cyclic union. We shouldn't be creating cyclic unions, but we shouldn't be crashing when they arise either. * Minor cleanup of `luau_precall` * Internal change to make L->top handling slightly more uniform * Optimize SETGLOBAL & GETGLOBAL fallback C functions. * https://github.com/Roblox/luau/pull/929 * The syntax to the `luau-reduce` commandline tool has changed. It now accepts a script, a command to execute, and an error to search for. It no longer automatically passes the script to the command which makes it a lot more flexible. Also be warned that it edits the script it is passed **in place**. Do not point it at something that is not in source control! New solver * Switch to a greedier but more fallible algorithm for simplifying union and intersection types that are created as part of refinement calculation. This has much better and more predictable performance. * Fix a constraint cycle in recursive function calls. * Much improved inference of binary addition. Functions like `function add(x, y) return x + y end` can now be inferred without annotations. We also accurately typecheck calls to functions like this. * Many small bugfixes surrounding things like table indexers * Add support for indexers on class types. This was previously added to the old solver; we now add it to the new one for feature parity. JIT * https://github.com/Roblox/luau/pull/931 * Fuse key.value and key.tt loads for CEHCK_SLOT_MATCH in A64 * Implement remaining aliases of BFM for A64 * Implement new callinfo flag for A64 * Add instruction simplification for int->num->int conversion chains * Don't even load execdata for X64 calls * Treat opcode fallbacks the same as manually written fallbacks --------- Co-authored-by: Arseny Kapoulkine <arseny.kapoulkine@gmail.com> Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>
2023-05-20 03:37:30 +08:00
}
TEST_CASE_FIXTURE(SimplifyFixture, "nested_table_tag_test")
{
TypeId t1 = mkTable({
{"subtable", mkTable({
{"tag", helloTy},
{"subprop", numberTy},
})},
{"prop", stringTy},
});
TypeId t2 = mkTable({
{"subtable", mkTable({
{"tag", helloTy},
})},
});
CHECK(t1 == intersect(t1, t2));
CHECK(t1 == intersect(t2, t1));
}
TEST_CASE_FIXTURE(SimplifyFixture, "union")
{
TypeId t1 = arena->addType(UnionType{{numberTy, stringTy, nilTy, tableTy}});
CHECK(nilTy == intersect(t1, nilTy));
// CHECK(nilTy == intersect(nilTy, t1)); // TODO?
CHECK(builtinTypes->stringType == intersect(builtinTypes->optionalStringType, truthyTy));
}
TEST_CASE_FIXTURE(SimplifyFixture, "two_unions")
{
TypeId t1 = arena->addType(UnionType{{numberTy, booleanTy, stringTy, nilTy, tableTy}});
CHECK("false?" == intersectStr(t1, falsyTy));
}
TEST_CASE_FIXTURE(SimplifyFixture, "curious_union")
{
// (a & false) | (a & nil)
TypeId curious =
arena->addType(UnionType{{arena->addType(IntersectionType{{freeTy, falseTy}}), arena->addType(IntersectionType{{freeTy, nilTy}})}});
CHECK("('a & false) | ('a & nil) | number" == toString(union_(curious, numberTy)));
Sync to upstream/release/577 (#934) Lots of things going on this week: * Fix a crash that could occur in the presence of a cyclic union. We shouldn't be creating cyclic unions, but we shouldn't be crashing when they arise either. * Minor cleanup of `luau_precall` * Internal change to make L->top handling slightly more uniform * Optimize SETGLOBAL & GETGLOBAL fallback C functions. * https://github.com/Roblox/luau/pull/929 * The syntax to the `luau-reduce` commandline tool has changed. It now accepts a script, a command to execute, and an error to search for. It no longer automatically passes the script to the command which makes it a lot more flexible. Also be warned that it edits the script it is passed **in place**. Do not point it at something that is not in source control! New solver * Switch to a greedier but more fallible algorithm for simplifying union and intersection types that are created as part of refinement calculation. This has much better and more predictable performance. * Fix a constraint cycle in recursive function calls. * Much improved inference of binary addition. Functions like `function add(x, y) return x + y end` can now be inferred without annotations. We also accurately typecheck calls to functions like this. * Many small bugfixes surrounding things like table indexers * Add support for indexers on class types. This was previously added to the old solver; we now add it to the new one for feature parity. JIT * https://github.com/Roblox/luau/pull/931 * Fuse key.value and key.tt loads for CEHCK_SLOT_MATCH in A64 * Implement remaining aliases of BFM for A64 * Implement new callinfo flag for A64 * Add instruction simplification for int->num->int conversion chains * Don't even load execdata for X64 calls * Treat opcode fallbacks the same as manually written fallbacks --------- Co-authored-by: Arseny Kapoulkine <arseny.kapoulkine@gmail.com> Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>
2023-05-20 03:37:30 +08:00
}
TEST_CASE_FIXTURE(SimplifyFixture, "negations")
{
TypeId notNumberTy = mkNegation(numberTy);
TypeId notStringTy = mkNegation(stringTy);
CHECK(neverTy == intersect(numberTy, notNumberTy));
CHECK(numberTy == intersect(numberTy, notStringTy));
CHECK(numberTy == intersect(notStringTy, numberTy));
}
TEST_CASE_FIXTURE(SimplifyFixture, "top_class_type")
{
CHECK(neverTy == intersect(classTy, stringTy));
}
TEST_CASE_FIXTURE(SimplifyFixture, "classes")
{
CHECK(childClassTy == intersect(childClassTy, parentClassTy));
CHECK(childClassTy == intersect(parentClassTy, childClassTy));
CHECK(parentClassTy == union_(childClassTy, parentClassTy));
CHECK(parentClassTy == union_(parentClassTy, childClassTy));
CHECK(neverTy == intersect(childClassTy, unrelatedClassTy));
}
TEST_CASE_FIXTURE(SimplifyFixture, "negations_of_classes")
{
TypeId notChildClassTy = mkNegation(childClassTy);
TypeId notParentClassTy = mkNegation(parentClassTy);
CHECK(neverTy == intersect(childClassTy, notParentClassTy));
CHECK(neverTy == intersect(notParentClassTy, childClassTy));
CHECK("Parent & ~Child" == intersectStr(notChildClassTy, parentClassTy));
CHECK("Parent & ~Child" == intersectStr(parentClassTy, notChildClassTy));
CHECK(notParentClassTy == intersect(notChildClassTy, notParentClassTy));
CHECK(notParentClassTy == intersect(notParentClassTy, notChildClassTy));
}
TEST_CASE_FIXTURE(SimplifyFixture, "intersection_of_intersection_of_a_free_type_can_result_in_removal_of_that_free_type")
{
// a & string and number
// (a & number) & (string & number)
TypeId t1 = arena->addType(IntersectionType{{freeTy, stringTy}});
CHECK(neverTy == intersect(t1, numberTy));
}
TEST_CASE_FIXTURE(SimplifyFixture, "some_tables_are_really_never")
{
TypeId notAnyTy = mkNegation(anyTy);
TypeId t1 = mkTable({{"someKey", notAnyTy}});
CHECK(neverTy == intersect(t1, numberTy));
CHECK(neverTy == intersect(numberTy, t1));
CHECK(neverTy == intersect(t1, t1));
}
TEST_CASE_FIXTURE(SimplifyFixture, "simplify_stops_at_cycles")
{
TypeId t = mkTable({});
TableType* tt = getMutable<TableType>(t);
REQUIRE(tt);
TypeId t2 = mkTable({});
TableType* t2t = getMutable<TableType>(t2);
REQUIRE(t2t);
tt->props["cyclic"] = Property{t2};
t2t->props["cyclic"] = Property{t};
CHECK(t == intersect(t, anyTy));
CHECK(t == intersect(anyTy, t));
CHECK(t2 == intersect(t2, anyTy));
CHECK(t2 == intersect(anyTy, t2));
}
TEST_CASE_FIXTURE(SimplifyFixture, "free_type_bound_by_any_with_any")
{
CHECK(freeTy == intersect(freeTy, anyTy));
CHECK(freeTy == intersect(anyTy, freeTy));
CHECK(freeTy == intersect(freeTy, anyTy));
CHECK(freeTy == intersect(anyTy, freeTy));
}
Sync to upstream/release/577 (#934) Lots of things going on this week: * Fix a crash that could occur in the presence of a cyclic union. We shouldn't be creating cyclic unions, but we shouldn't be crashing when they arise either. * Minor cleanup of `luau_precall` * Internal change to make L->top handling slightly more uniform * Optimize SETGLOBAL & GETGLOBAL fallback C functions. * https://github.com/Roblox/luau/pull/929 * The syntax to the `luau-reduce` commandline tool has changed. It now accepts a script, a command to execute, and an error to search for. It no longer automatically passes the script to the command which makes it a lot more flexible. Also be warned that it edits the script it is passed **in place**. Do not point it at something that is not in source control! New solver * Switch to a greedier but more fallible algorithm for simplifying union and intersection types that are created as part of refinement calculation. This has much better and more predictable performance. * Fix a constraint cycle in recursive function calls. * Much improved inference of binary addition. Functions like `function add(x, y) return x + y end` can now be inferred without annotations. We also accurately typecheck calls to functions like this. * Many small bugfixes surrounding things like table indexers * Add support for indexers on class types. This was previously added to the old solver; we now add it to the new one for feature parity. JIT * https://github.com/Roblox/luau/pull/931 * Fuse key.value and key.tt loads for CEHCK_SLOT_MATCH in A64 * Implement remaining aliases of BFM for A64 * Implement new callinfo flag for A64 * Add instruction simplification for int->num->int conversion chains * Don't even load execdata for X64 calls * Treat opcode fallbacks the same as manually written fallbacks --------- Co-authored-by: Arseny Kapoulkine <arseny.kapoulkine@gmail.com> Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>
2023-05-20 03:37:30 +08:00
TEST_SUITE_END();