mirror of
https://github.com/luau-lang/luau.git
synced 2025-08-26 11:27:08 +01:00
# General * Expose an optional `get_alias` API as an alternative to `get_config` in Luau.Require and Luau.RequireNavigator. * Improve the Luau CLI's virtual filesystem implementation to fix bugs related to `init.luau`. Fixes https://github.com/luau-lang/luau/issues/1816 # New Type Solver * Avoid double reporting errors when erroneous arguments are provided to type functions. * Fix some instances of unresovable cyclic type functions in loops by only considering the first loop cycles. This results in some type inference inaccuracies when the type of a variable in loop through multiple iterations. Fixes https://github.com/luau-lang/luau/issues/1413. * Better generalize free types that have meaningful lower and upper bounds, especially for table indexers. * Report more specific errors when assigning or returning table literal types, instead of citing the *entire* table type. * Inference for functions with generic type packs is greatly improved. * Fix some internal compiler exceptions when using type-stating functions like `table.freeze` in `if _ then _ else _` expressions and short circuiting binary operations. * More consistently simplify unions of primitive types, especially in array-like and dictionary-like tables. * Fix a crash when type checking an erroneous type alias containing `typeof` with a type assertion expression, as in: ``` type MyTable = {} -- This will error at type checking time as it's a duplicate type MyTable = typeof(setmetatable(SomeTable :: {}, SomeMetaTable)); ``` * Fix a crash when inferring the type of an index expression where the indexee is invalid (e.g. `nil`). # Runtime * Avoid throwing an exception from `luau_load` if we run out of memory. * Type functions are no longer compiled and included in bytecode. Fixes #1817. * Fix some instances of Luau C API functions reading invalid debug information (generally when the first or last instruction of a block was being inspected). Fixes #1369. * Avoid potential signed integer overflow when doing bounds checks on tables. * Support 16 byte aligned userdata objects when system allocation alignment is also 16 bytes. * Fix memory leaks in `Luau.Require` when using VM build with no exceptions. Fixes #1827. --------- Co-authored-by: Andy Friesen <afriesen@roblox.com> Co-authored-by: Ariel Weiss <aaronweiss@roblox.com> Co-authored-by: Hunter Goldstein <hgoldstein@roblox.com> Co-authored-by: James McNellis <jmcnellis@roblox.com> Co-authored-by: Sora Kanosue <skanosue@roblox.com> Co-authored-by: Talha Pathan <tpathan@roblox.com> Co-authored-by: Varun Saini <vsaini@roblox.com> Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>
89 lines
1.7 KiB
C++
89 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
|
|
#pragma once
|
|
|
|
#include "Luau/Common.h"
|
|
#include "Luau/Location.h"
|
|
#include "Luau/Lexer.h"
|
|
#include "Luau/StringUtils.h"
|
|
|
|
namespace Luau
|
|
{
|
|
|
|
class AstStatBlock;
|
|
class CstNode;
|
|
|
|
class ParseError : public std::exception
|
|
{
|
|
public:
|
|
ParseError(const Location& location, const std::string& message);
|
|
|
|
virtual const char* what() const throw();
|
|
|
|
const Location& getLocation() const;
|
|
const std::string& getMessage() const;
|
|
|
|
static LUAU_NORETURN void raise(const Location& location, const char* format, ...) LUAU_PRINTF_ATTR(2, 3);
|
|
|
|
private:
|
|
Location location;
|
|
std::string message;
|
|
};
|
|
|
|
class ParseErrors : public std::exception
|
|
{
|
|
public:
|
|
ParseErrors(std::vector<ParseError> errors);
|
|
|
|
virtual const char* what() const throw();
|
|
|
|
const std::vector<ParseError>& getErrors() const;
|
|
|
|
private:
|
|
std::vector<ParseError> errors;
|
|
std::string message;
|
|
};
|
|
|
|
struct HotComment
|
|
{
|
|
bool header;
|
|
Location location;
|
|
std::string content;
|
|
};
|
|
|
|
struct Comment
|
|
{
|
|
Lexeme::Type type; // Comment, BlockComment, or BrokenComment
|
|
Location location;
|
|
};
|
|
|
|
using CstNodeMap = DenseHashMap<AstNode*, CstNode*>;
|
|
|
|
struct ParseResult
|
|
{
|
|
AstStatBlock* root;
|
|
size_t lines = 0;
|
|
|
|
std::vector<HotComment> hotcomments;
|
|
std::vector<ParseError> errors;
|
|
|
|
std::vector<Comment> commentLocations;
|
|
|
|
CstNodeMap cstNodeMap{nullptr};
|
|
};
|
|
|
|
struct ParseExprResult
|
|
{
|
|
AstExpr* expr;
|
|
size_t lines = 0;
|
|
|
|
std::vector<HotComment> hotcomments;
|
|
std::vector<ParseError> errors;
|
|
|
|
std::vector<Comment> commentLocations;
|
|
|
|
CstNodeMap cstNodeMap{nullptr};
|
|
};
|
|
|
|
inline constexpr const char* kParseNameError = "%error-id%";
|
|
|
|
} // namespace Luau
|