mirror of
https://github.com/luau-lang/luau.git
synced 2025-08-26 11:27:08 +01:00
# What's Changed? We've been hard at work fixing bugs and introducing new features! ## VM * Include constant-folding information in Luau cost model for inlining and loop unrolling * ~1% improvement in compile times ## New Type Solver * `Luau::shallowClone`'s last argument, whether to clone persistent (builtin) types, is now non-optional. * Refinements on properties of tables are now computed with a `read` table property. This resolves some issues around refining table properies and then trying to set them. Fixes #1344. Fixes #1651. ``` if foo.bar then -- Prior to this release, this would be `typeof(foo) & { bar: ~(false?) } -- Now, this is `typeof(foo) & { read bar: ~(false?) } end ``` * The type function `keyof` should respect the empty string as a property, as in: ``` -- equivalent to type Foo ="" type Foo = keyof<{ [""]: number }> ``` * Descend into literals to report subtyping errors for function calls: this both improves bidirectional inference and makes errors more specific. Before, the error reporting for a table with incorrect members passed to a function would cite the entire table, but now it only cites the members that are incorrectly typed. * Fixes a case where intersecting two tables without any common properties would create `never`, instead of a table with both of their properties. # Internal Contributors 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: Vighnesh Vijay <vvijay@roblox.com> Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com> --------- Co-authored-by: Hunter Goldstein <hgoldstein@roblox.com> Co-authored-by: Varun Saini <61795485+vrn-sn@users.noreply.github.com> Co-authored-by: Alexander Youngblood <ayoungblood@roblox.com> Co-authored-by: Aviral Goel <agoel@roblox.com> Co-authored-by: Vighnesh <vvijay@roblox.com> Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com> Co-authored-by: Ariel Weiss <aaronweiss@roblox.com> Co-authored-by: Andy Friesen <afriesen@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, 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
|