mirror of
https://github.com/luau-lang/luau.git
synced 2024-11-15 14:25:44 +08:00
ce8495a69e
# What's Changed? - Code refactoring with a new clang-format - More bug fixes / test case fixes in the new solver ## New Solver - More precise telemetry collection of `any` types - Simplification of two completely disjoint tables combines them into a single table that inherits all properties / indexers - Refining a `never & <anything>` does not produce type family types nor constraints - Silence "inference failed to complete" error when it is the only error reported --- ### Internal Contributors Co-authored-by: Aaron Weiss <aaronweiss@roblox.com> Co-authored-by: Andy Friesen <afriesen@roblox.com> Co-authored-by: Dibri Nsofor <dnsofor@roblox.com> Co-authored-by: Jeremy Yoo <jyoo@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: Vighnesh <vvijay@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>
83 lines
2.9 KiB
C++
83 lines
2.9 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/Scope.h"
|
|
#include "Luau/Type.h"
|
|
|
|
#include <optional>
|
|
|
|
namespace Luau
|
|
{
|
|
|
|
struct Frontend;
|
|
struct GlobalTypes;
|
|
struct TypeChecker;
|
|
struct TypeArena;
|
|
|
|
void registerBuiltinGlobals(Frontend& frontend, GlobalTypes& globals, bool typeCheckForAutocomplete = false);
|
|
TypeId makeUnion(TypeArena& arena, std::vector<TypeId>&& types);
|
|
TypeId makeIntersection(TypeArena& arena, std::vector<TypeId>&& types);
|
|
|
|
/** Build an optional 't'
|
|
*/
|
|
TypeId makeOption(NotNull<BuiltinTypes> builtinTypes, TypeArena& arena, TypeId t);
|
|
|
|
/** Small utility function for building up type definitions from C++.
|
|
*/
|
|
TypeId makeFunction( // Monomorphic
|
|
TypeArena& arena,
|
|
std::optional<TypeId> selfType,
|
|
std::initializer_list<TypeId> paramTypes,
|
|
std::initializer_list<TypeId> retTypes,
|
|
bool checked = false
|
|
);
|
|
|
|
TypeId makeFunction( // Polymorphic
|
|
TypeArena& arena,
|
|
std::optional<TypeId> selfType,
|
|
std::initializer_list<TypeId> generics,
|
|
std::initializer_list<TypePackId> genericPacks,
|
|
std::initializer_list<TypeId> paramTypes,
|
|
std::initializer_list<TypeId> retTypes,
|
|
bool checked = false
|
|
);
|
|
|
|
TypeId makeFunction( // Monomorphic
|
|
TypeArena& arena,
|
|
std::optional<TypeId> selfType,
|
|
std::initializer_list<TypeId> paramTypes,
|
|
std::initializer_list<std::string> paramNames,
|
|
std::initializer_list<TypeId> retTypes,
|
|
bool checked = false
|
|
);
|
|
|
|
TypeId makeFunction( // Polymorphic
|
|
TypeArena& arena,
|
|
std::optional<TypeId> selfType,
|
|
std::initializer_list<TypeId> generics,
|
|
std::initializer_list<TypePackId> genericPacks,
|
|
std::initializer_list<TypeId> paramTypes,
|
|
std::initializer_list<std::string> paramNames,
|
|
std::initializer_list<TypeId> retTypes,
|
|
bool checked = false
|
|
);
|
|
|
|
void attachMagicFunction(TypeId ty, MagicFunction fn);
|
|
void attachDcrMagicFunction(TypeId ty, DcrMagicFunction fn);
|
|
void attachDcrMagicRefinement(TypeId ty, DcrMagicRefinement fn);
|
|
|
|
Property makeProperty(TypeId ty, std::optional<std::string> documentationSymbol = std::nullopt);
|
|
void assignPropDocumentationSymbols(TableType::Props& props, const std::string& baseName);
|
|
|
|
std::string getBuiltinDefinitionSource();
|
|
|
|
void addGlobalBinding(GlobalTypes& globals, const std::string& name, TypeId ty, const std::string& packageName);
|
|
void addGlobalBinding(GlobalTypes& globals, const std::string& name, Binding binding);
|
|
void addGlobalBinding(GlobalTypes& globals, const ScopePtr& scope, const std::string& name, TypeId ty, const std::string& packageName);
|
|
void addGlobalBinding(GlobalTypes& globals, const ScopePtr& scope, const std::string& name, Binding binding);
|
|
std::optional<Binding> tryGetGlobalBinding(GlobalTypes& globals, const std::string& name);
|
|
Binding* tryGetGlobalBindingRef(GlobalTypes& globals, const std::string& name);
|
|
TypeId getGlobalBinding(GlobalTypes& globals, const std::string& name);
|
|
|
|
} // namespace Luau
|