mirror of
https://github.com/luau-lang/luau.git
synced 2024-11-15 14:25:44 +08:00
4b267aa5c5
* Added a limit on how many instructions the Compiler can safely produce (reported by @TheGreatSageEqualToHeaven) C++ API Changes: * With work started on read-only and write-only properties, `Property::type` member variable has been replaced with `TypeId type()` and `setType(TypeId)` functions. * New `LazyType` unwrap callback now has a `void` return type, all that's required from the callback is to write into `unwrapped` field. In our work on the new type solver, the following issues were fixed: * Work has started to support https://github.com/Roblox/luau/pull/77 and https://github.com/Roblox/luau/pull/79 * Refinements are no longer applied on l-values, removing some false-positive errors * Improved overload resolution against expected result type * `Frontend::prepareModuleScope` now works in the new solver * Cofinite strings are now comparable And these are the changes in native code generation (JIT): * Fixed MIN_NUM and MAX_NUM constant fold when one of the arguments is NaN * Added constant folding for number conversions and bit operations * Value spilling and rematerialization is now supported on arm64 * Improved FASTCALL2K IR generation to support second argument constant * Added value numbering and load/store propagation optimizations * Added STORE_VECTOR on arm64, completing the IR lowering on this target
80 lines
1.7 KiB
C++
80 lines
1.7 KiB
C++
// This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
|
|
|
|
#include "Fixture.h"
|
|
|
|
#include "Luau/ToString.h"
|
|
#include "doctest.h"
|
|
#include "Luau/Common.h"
|
|
#include "ScopedFlags.h"
|
|
|
|
using namespace Luau;
|
|
|
|
namespace
|
|
{
|
|
|
|
struct NegationFixture : Fixture
|
|
{
|
|
TypeArena arena;
|
|
|
|
NegationFixture()
|
|
{
|
|
registerHiddenTypes(&frontend);
|
|
}
|
|
};
|
|
|
|
} // namespace
|
|
|
|
TEST_SUITE_BEGIN("Negations");
|
|
|
|
TEST_CASE_FIXTURE(NegationFixture, "negated_string_is_a_subtype_of_string")
|
|
{
|
|
CheckResult result = check(R"(
|
|
function foo(arg: string) end
|
|
local a: string & Not<"Hello">
|
|
foo(a)
|
|
)");
|
|
|
|
LUAU_REQUIRE_NO_ERRORS(result);
|
|
}
|
|
|
|
TEST_CASE_FIXTURE(NegationFixture, "string_is_not_a_subtype_of_negated_string")
|
|
{
|
|
CheckResult result = check(R"(
|
|
function foo(arg: string & Not<"hello">) end
|
|
local a: string
|
|
foo(a)
|
|
)");
|
|
|
|
LUAU_REQUIRE_ERROR_COUNT(1, result);
|
|
}
|
|
|
|
TEST_CASE_FIXTURE(Fixture, "cofinite_strings_can_be_compared_for_equality")
|
|
{
|
|
CheckResult result = check(R"(
|
|
function f(e)
|
|
if e == 'strictEqual' then
|
|
e = 'strictEqualObject'
|
|
end
|
|
if e == 'deepStrictEqual' or e == 'strictEqual' then
|
|
elseif e == 'notDeepStrictEqual' or e == 'notStrictEqual' then
|
|
end
|
|
return e
|
|
end
|
|
)");
|
|
|
|
LUAU_REQUIRE_NO_ERRORS(result);
|
|
CHECK("(string) -> string" == toString(requireType("f")));
|
|
}
|
|
|
|
TEST_CASE_FIXTURE(NegationFixture, "compare_cofinite_strings")
|
|
{
|
|
CheckResult result = check(R"(
|
|
local u : Not<"a">
|
|
local v : "b"
|
|
if u == v then
|
|
end
|
|
)");
|
|
LUAU_REQUIRE_NO_ERRORS(result);
|
|
}
|
|
TEST_SUITE_END();
|