-
Notifications
You must be signed in to change notification settings - Fork 381
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fixed indexing table intersections using `x["prop"]` syntax: #971 * Add console output codepage for Windows: #967 * Added `Frontend::parse` for a fast source graph preparation * luau_load should check GC * Work toward a type-diff system for nicer error messages New Solver * Correctly suppress errors in more cases * Further improvements to typechecking of function calls and return statements * Crash fixes * Propagate refinements drawn from the condition of a while loop into the loop body JIT * Fix accidental bailout for math.frexp/modf/sign in A64 * Work toward bringing type annotation info in * Do not propagate Luau IR constants of wrong type into load instructions * CHECK_SAFEENV exits to VM on failure * Implement error handling in A64 reg allocator * Inline the string.len builtin * Do not enter native code of a function if arguments don’t match --------- Co-authored-by: Arseny Kapoulkine <arseny.kapoulkine@gmail.com> Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>
- Loading branch information
1 parent
c98a9d7
commit e25de95
Showing
68 changed files
with
1,893 additions
and
293 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
// This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details | ||
#pragma once | ||
|
||
#include "Luau/Type.h" | ||
#include <optional> | ||
#include <string> | ||
|
||
namespace Luau | ||
{ | ||
struct DiffPathNode | ||
{ | ||
// TODO: consider using Variants to simplify toString implementation | ||
enum Kind | ||
{ | ||
TableProperty, | ||
FunctionArgument, | ||
FunctionReturn, | ||
Union, | ||
Intersection, | ||
}; | ||
Kind kind; | ||
// non-null when TableProperty | ||
std::optional<Name> tableProperty; | ||
// non-null when FunctionArgument, FunctionReturn, Union, or Intersection (i.e. anonymous fields) | ||
std::optional<int> index; | ||
|
||
/** | ||
* Do not use for leaf nodes | ||
*/ | ||
DiffPathNode(Kind kind) | ||
: kind(kind) | ||
{ | ||
} | ||
|
||
DiffPathNode(Kind kind, std::optional<Name> tableProperty, std::optional<int> index) | ||
: kind(kind) | ||
, tableProperty(tableProperty) | ||
, index(index) | ||
{ | ||
} | ||
|
||
std::string toString() const; | ||
|
||
static DiffPathNode constructWithTableProperty(Name tableProperty); | ||
}; | ||
struct DiffPathNodeLeaf | ||
{ | ||
std::optional<TypeId> ty; | ||
std::optional<Name> tableProperty; | ||
DiffPathNodeLeaf(std::optional<TypeId> ty, std::optional<Name> tableProperty) | ||
: ty(ty) | ||
, tableProperty(tableProperty) | ||
{ | ||
} | ||
|
||
static DiffPathNodeLeaf nullopts(); | ||
}; | ||
struct DiffPath | ||
{ | ||
std::vector<DiffPathNode> path; | ||
|
||
std::string toString(bool prependDot) const; | ||
}; | ||
struct DiffError | ||
{ | ||
enum Kind | ||
{ | ||
Normal, | ||
MissingProperty, | ||
LengthMismatchInFnArgs, | ||
LengthMismatchInFnRets, | ||
LengthMismatchInUnion, | ||
LengthMismatchInIntersection, | ||
}; | ||
Kind kind; | ||
|
||
DiffPath diffPath; | ||
DiffPathNodeLeaf left; | ||
DiffPathNodeLeaf right; | ||
|
||
std::string leftRootName; | ||
std::string rightRootName; | ||
|
||
DiffError(Kind kind, DiffPathNodeLeaf left, DiffPathNodeLeaf right, std::string leftRootName, std::string rightRootName) | ||
: kind(kind) | ||
, left(left) | ||
, right(right) | ||
, leftRootName(leftRootName) | ||
, rightRootName(rightRootName) | ||
{ | ||
checkValidInitialization(left, right); | ||
} | ||
DiffError(Kind kind, DiffPath diffPath, DiffPathNodeLeaf left, DiffPathNodeLeaf right, std::string leftRootName, std::string rightRootName) | ||
: kind(kind) | ||
, diffPath(diffPath) | ||
, left(left) | ||
, right(right) | ||
, leftRootName(leftRootName) | ||
, rightRootName(rightRootName) | ||
{ | ||
checkValidInitialization(left, right); | ||
} | ||
|
||
std::string toString() const; | ||
|
||
private: | ||
std::string toStringALeaf(std::string rootName, const DiffPathNodeLeaf& leaf, const DiffPathNodeLeaf& otherLeaf) const; | ||
void checkValidInitialization(const DiffPathNodeLeaf& left, const DiffPathNodeLeaf& right); | ||
void checkNonMissingPropertyLeavesHaveNulloptTableProperty() const; | ||
}; | ||
|
||
struct DifferResult | ||
{ | ||
std::optional<DiffError> diffError; | ||
|
||
DifferResult() {} | ||
DifferResult(DiffError diffError) | ||
: diffError(diffError) | ||
{ | ||
} | ||
|
||
void wrapDiffPath(DiffPathNode node); | ||
}; | ||
struct DifferEnvironment | ||
{ | ||
TypeId rootLeft; | ||
TypeId rootRight; | ||
}; | ||
DifferResult diff(TypeId ty1, TypeId ty2); | ||
|
||
/** | ||
* True if ty is a "simple" type, i.e. cannot contain types. | ||
* string, number, boolean are simple types. | ||
* function and table are not simple types. | ||
*/ | ||
bool isSimple(TypeId ty); | ||
|
||
} // namespace Luau |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.