mirror of
https://github.com/luau-lang/luau.git
synced 2024-12-13 21:40:43 +00:00
59ae47db43
* Type mismatch errors now mention if unification failed in covariant or invariant context, to explain why sometimes derived class can't be converted to base class or why `T` can't be converted into `T?` and so on * Class type indexing is no longer an error in non-strict mode (still an error in strict mode) * Fixed cyclic type packs not being displayed in the type * Added an error when unrelated types are compared with `==`/`~=` * Fixed false positive errors involving sub-type tests an `never` type * Fixed miscompilation of multiple assignment statements (Fixes https://github.com/Roblox/luau/issues/754) * Type inference stability improvements
70 lines
1.4 KiB
C++
70 lines
1.4 KiB
C++
// This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
|
|
#pragma once
|
|
|
|
#include "Luau/Def.h"
|
|
#include "Luau/TypedAllocator.h"
|
|
#include "Luau/Variant.h"
|
|
|
|
#include <memory>
|
|
|
|
namespace Luau
|
|
{
|
|
|
|
struct TypeVar;
|
|
using TypeId = const TypeVar*;
|
|
|
|
struct Negation;
|
|
struct Conjunction;
|
|
struct Disjunction;
|
|
struct Equivalence;
|
|
struct Proposition;
|
|
using Connective = Variant<Negation, Conjunction, Disjunction, Equivalence, Proposition>;
|
|
using ConnectiveId = Connective*; // Can and most likely is nullptr.
|
|
|
|
struct Negation
|
|
{
|
|
ConnectiveId connective;
|
|
};
|
|
|
|
struct Conjunction
|
|
{
|
|
ConnectiveId lhs;
|
|
ConnectiveId rhs;
|
|
};
|
|
|
|
struct Disjunction
|
|
{
|
|
ConnectiveId lhs;
|
|
ConnectiveId rhs;
|
|
};
|
|
|
|
struct Equivalence
|
|
{
|
|
ConnectiveId lhs;
|
|
ConnectiveId rhs;
|
|
};
|
|
|
|
struct Proposition
|
|
{
|
|
DefId def;
|
|
TypeId discriminantTy;
|
|
};
|
|
|
|
template<typename T>
|
|
const T* get(ConnectiveId connective)
|
|
{
|
|
return get_if<T>(connective);
|
|
}
|
|
|
|
struct ConnectiveArena
|
|
{
|
|
TypedAllocator<Connective> allocator;
|
|
|
|
ConnectiveId negation(ConnectiveId connective);
|
|
ConnectiveId conjunction(ConnectiveId lhs, ConnectiveId rhs);
|
|
ConnectiveId disjunction(ConnectiveId lhs, ConnectiveId rhs);
|
|
ConnectiveId equivalence(ConnectiveId lhs, ConnectiveId rhs);
|
|
ConnectiveId proposition(DefId def, TypeId discriminantTy);
|
|
};
|
|
|
|
} // namespace Luau
|