Skip to content

Commit c219e40

Browse files
committed
Bump Luau to 0.705
1 parent 50d5d71 commit c219e40

68 files changed

Lines changed: 5382 additions & 969 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

luau/Ast/include/Luau/Ast.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1458,6 +1458,10 @@ class AstVisitor
14581458
{
14591459
return visit(static_cast<AstExpr*>(node));
14601460
}
1461+
virtual bool visit(class AstExprInstantiate* node)
1462+
{
1463+
return visit(static_cast<AstExpr*>(node));
1464+
}
14611465
virtual bool visit(class AstExprError* node)
14621466
{
14631467
return visit(static_cast<AstExpr*>(node));

luau/Ast/include/Luau/ParseResult.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class ParseError : public std::exception
1717
public:
1818
ParseError(const Location& location, std::string message);
1919

20-
virtual const char* what() const throw();
20+
const char* what() const throw() override;
2121

2222
const Location& getLocation() const;
2323
const std::string& getMessage() const;
@@ -34,7 +34,7 @@ class ParseErrors : public std::exception
3434
public:
3535
ParseErrors(std::vector<ParseError> errors);
3636

37-
virtual const char* what() const throw();
37+
const char* what() const throw() override;
3838

3939
const std::vector<ParseError>& getErrors() const;
4040

luau/Ast/src/Ast.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
LUAU_FASTFLAGVARIABLE(LuauStandaloneParseType)
77

8-
LUAU_FASTFLAG(LuauExplicitTypeExpressionInstantiation)
8+
LUAU_FASTFLAG(LuauExplicitTypeInstantiationSyntax)
99

1010
namespace Luau
1111
{
@@ -37,7 +37,7 @@ static void visitTypeList(AstVisitor* visitor, const AstTypeList& list)
3737

3838
static void visitTypeOrPackArray(AstVisitor* visitor, const AstArray<AstTypeOrPack>& arrayOfTypeOrPack)
3939
{
40-
LUAU_ASSERT(FFlag::LuauExplicitTypeExpressionInstantiation);
40+
LUAU_ASSERT(FFlag::LuauExplicitTypeInstantiationSyntax);
4141

4242
for (const AstTypeOrPack& param : arrayOfTypeOrPack)
4343
{
@@ -241,7 +241,7 @@ AstExprCall::AstExprCall(
241241
, self(self)
242242
, argLocation(argLocation)
243243
{
244-
LUAU_ASSERT(FFlag::LuauExplicitTypeExpressionInstantiation || explicitTypes.size == 0);
244+
LUAU_ASSERT(FFlag::LuauExplicitTypeInstantiationSyntax || explicitTypes.size == 0);
245245
}
246246

247247
void AstExprCall::visit(AstVisitor* visitor)
@@ -552,11 +552,13 @@ AstExprInstantiate::AstExprInstantiate(const Location& location, AstExpr* expr,
552552
, expr(expr)
553553
, typeArguments(types)
554554
{
555-
LUAU_ASSERT(FFlag::LuauExplicitTypeExpressionInstantiation);
555+
LUAU_ASSERT(FFlag::LuauExplicitTypeInstantiationSyntax);
556556
}
557557

558558
void AstExprInstantiate::visit(AstVisitor* visitor)
559559
{
560+
expr->visit(visitor);
561+
560562
if (visitor->visit(this))
561563
{
562564
visitTypeOrPackArray(visitor, typeArguments);
@@ -1098,7 +1100,7 @@ void AstTypeReference::visit(AstVisitor* visitor)
10981100
{
10991101
if (visitor->visit(this))
11001102
{
1101-
if (FFlag::LuauExplicitTypeExpressionInstantiation)
1103+
if (FFlag::LuauExplicitTypeInstantiationSyntax)
11021104
{
11031105
visitTypeOrPackArray(visitor, parameters);
11041106
}

luau/Ast/src/Parser.cpp

Lines changed: 23 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@ LUAU_FASTINTVARIABLE(LuauParseErrorLimit, 100)
1919
// See docs/SyntaxChanges.md for an explanation.
2020
LUAU_FASTFLAGVARIABLE(LuauSolverV2)
2121
LUAU_DYNAMIC_FASTFLAGVARIABLE(DebugLuauReportReturnTypeVariadicWithTypeSuffix, false)
22-
LUAU_FASTFLAGVARIABLE(DebugLuauStringSingletonBasedOnQuotes)
23-
LUAU_FASTFLAGVARIABLE(LuauExplicitTypeExpressionInstantiation)
24-
LUAU_FASTFLAGVARIABLE(LuauAutocompleteAttributes)
22+
LUAU_FASTFLAGVARIABLE(LuauExplicitTypeInstantiationSyntax)
2523
LUAU_FASTFLAG(LuauStandaloneParseType)
2624
LUAU_FASTFLAGVARIABLE(LuauCstStatDoWithStatsStart)
2725

@@ -951,15 +949,7 @@ void Parser::parseAttribute(TempVector<AstAttr*>& attributes)
951949

952950
nextLexeme();
953951

954-
if (FFlag::LuauAutocompleteAttributes)
955-
{
956-
attributes.push_back(allocator.alloc<AstAttr>(loc, type.value_or(AstAttr::Type::Unknown), empty, AstName(name)));
957-
}
958-
else
959-
{
960-
if (type)
961-
attributes.push_back(allocator.alloc<AstAttr>(loc, *type, empty));
962-
}
952+
attributes.push_back(allocator.alloc<AstAttr>(loc, type.value_or(AstAttr::Type::Unknown), empty, AstName(name)));
963953
}
964954
else
965955
{
@@ -989,30 +979,14 @@ void Parser::parseAttribute(TempVector<AstAttr*>& attributes)
989979

990980
std::optional<AstAttr::Type> type = validateAttribute(nameLoc, attrName, attributes, args);
991981

992-
if (FFlag::LuauAutocompleteAttributes)
993-
{
994-
attributes.push_back(
995-
allocator.alloc<AstAttr>(Location(nameLoc, argsLocation), type.value_or(AstAttr::Type::Unknown), args, AstName(attrName))
996-
);
997-
}
998-
else
999-
{
1000-
if (type)
1001-
attributes.push_back(allocator.alloc<AstAttr>(Location(nameLoc, argsLocation), *type, args));
1002-
}
982+
attributes.push_back(
983+
allocator.alloc<AstAttr>(Location(nameLoc, argsLocation), type.value_or(AstAttr::Type::Unknown), args, AstName(attrName))
984+
);
1003985
}
1004986
else
1005987
{
1006988
std::optional<AstAttr::Type> type = validateAttribute(nameLoc, attrName, attributes, empty);
1007-
if (FFlag::LuauAutocompleteAttributes)
1008-
{
1009-
attributes.push_back(allocator.alloc<AstAttr>(nameLoc, type.value_or(AstAttr::Type::Unknown), empty, AstName(attrName)));
1010-
}
1011-
else
1012-
{
1013-
if (type)
1014-
attributes.push_back(allocator.alloc<AstAttr>(nameLoc, *type, empty));
1015-
}
989+
attributes.push_back(allocator.alloc<AstAttr>(nameLoc, type.value_or(AstAttr::Type::Unknown), empty, AstName(attrName)));
1016990
}
1017991

1018992
if (lexer.current().type == ',')
@@ -1029,13 +1003,10 @@ void Parser::parseAttribute(TempVector<AstAttr*>& attributes)
10291003
{
10301004
report(Location(open.location, lexer.current().location), "Attribute list cannot be empty");
10311005

1032-
if (FFlag::LuauAutocompleteAttributes)
1033-
{
1034-
// autocomplete expects at least one unknown attribute.
1035-
attributes.push_back(
1036-
allocator.alloc<AstAttr>(Location(open.location, lexer.current().location), AstAttr::Type::Unknown, empty, nameError)
1037-
);
1038-
}
1006+
// autocomplete expects at least one unknown attribute.
1007+
attributes.push_back(
1008+
allocator.alloc<AstAttr>(Location(open.location, lexer.current().location), AstAttr::Type::Unknown, empty, nameError)
1009+
);
10391010
}
10401011

10411012
expectMatchAndConsume(']', open);
@@ -3115,7 +3086,7 @@ AstExpr* Parser::parsePrimaryExpr(bool asStatement)
31153086
{
31163087
expr = parseFunctionArgs(expr, false);
31173088
}
3118-
else if (FFlag::LuauExplicitTypeExpressionInstantiation && lexer.current().type == '<' && lexer.lookahead().type == '<')
3089+
else if (FFlag::LuauExplicitTypeInstantiationSyntax && lexer.current().type == '<' && lexer.lookahead().type == '<')
31193090
{
31203091
expr = parseExplicitTypeInstantiationExpr(start, *expr);
31213092
}
@@ -3141,7 +3112,7 @@ AstExpr* Parser::parseMethodCall(Position start, AstExpr* expr)
31413112
Name index = parseIndexName("method name", opPosition);
31423113
AstExpr* func = allocator.alloc<AstExprIndexName>(Location(start, index.location.end), expr, index.name, index.location, opPosition, ':');
31433114

3144-
if (FFlag::LuauExplicitTypeExpressionInstantiation)
3115+
if (FFlag::LuauExplicitTypeInstantiationSyntax)
31453116
{
31463117
AstArray<AstTypeOrPack> typeArguments;
31473118
CstTypeInstantiation* cstTypeArguments = options.storeCstData ? allocator.alloc<CstTypeInstantiation>() : nullptr;
@@ -3949,38 +3920,17 @@ AstExpr* Parser::parseString()
39493920
Location location = lexer.current().location;
39503921

39513922
AstExprConstantString::QuoteStyle style;
3952-
if (FFlag::DebugLuauStringSingletonBasedOnQuotes)
3953-
{
3954-
switch (lexer.current().type)
3955-
{
3956-
case Lexeme::InterpStringSimple:
3957-
style = AstExprConstantString::QuotedSimple;
3958-
break;
3959-
case Lexeme::RawString:
3960-
style = AstExprConstantString::QuotedRaw;
3961-
break;
3962-
case Lexeme::QuotedString:
3963-
style = lexer.current().getQuoteStyle() == Lexeme::QuoteStyle::Single ? AstExprConstantString::QuotedSingle
3964-
: AstExprConstantString::QuotedSimple;
3965-
break;
3966-
default:
3967-
LUAU_ASSERT(false && "Invalid string type");
3968-
}
3969-
}
3970-
else
3923+
switch (lexer.current().type)
39713924
{
3972-
switch (lexer.current().type)
3973-
{
3974-
case Lexeme::QuotedString:
3975-
case Lexeme::InterpStringSimple:
3976-
style = AstExprConstantString::QuotedSimple;
3977-
break;
3978-
case Lexeme::RawString:
3979-
style = AstExprConstantString::QuotedRaw;
3980-
break;
3981-
default:
3982-
LUAU_ASSERT(false && "Invalid string type");
3983-
}
3925+
case Lexeme::QuotedString:
3926+
case Lexeme::InterpStringSimple:
3927+
style = AstExprConstantString::QuotedSimple;
3928+
break;
3929+
case Lexeme::RawString:
3930+
style = AstExprConstantString::QuotedRaw;
3931+
break;
3932+
default:
3933+
LUAU_ASSERT(false && "Invalid string type");
39843934
}
39853935

39863936
CstExprConstantString::QuoteStyle fullStyle;
@@ -4142,7 +4092,7 @@ LUAU_NOINLINE AstExpr* Parser::parseExplicitTypeInstantiationExpr(Position start
41424092

41434093
AstArray<AstTypeOrPack> Parser::parseTypeInstantiationExpr(CstTypeInstantiation* cstNodeOut, Location* endLocationOut)
41444094
{
4145-
LUAU_ASSERT(FFlag::LuauExplicitTypeExpressionInstantiation);
4095+
LUAU_ASSERT(FFlag::LuauExplicitTypeInstantiationSyntax);
41464096

41474097
LUAU_ASSERT(lexer.current().type == '<' && lexer.lookahead().type == '<');
41484098

luau/Ast/src/PrettyPrinter.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include <limits>
1010
#include <math.h>
1111

12-
LUAU_FASTFLAG(LuauExplicitTypeExpressionInstantiation)
12+
LUAU_FASTFLAG(LuauExplicitTypeInstantiationSyntax)
1313
LUAU_FASTFLAG(LuauCstStatDoWithStatsStart)
1414

1515
namespace
@@ -541,7 +541,7 @@ struct Printer
541541

542542
const auto cstNode = lookupCstNode<CstExprCall>(a);
543543

544-
if (FFlag::LuauExplicitTypeExpressionInstantiation)
544+
if (FFlag::LuauExplicitTypeInstantiationSyntax)
545545
{
546546
if (writeTypes && (a->typeArguments.size > 0 || (cstNode && cstNode->explicitTypes)))
547547
{
@@ -831,7 +831,7 @@ struct Printer
831831
}
832832
else if (const auto& a = expr.as<AstExprInstantiate>())
833833
{
834-
LUAU_ASSERT(FFlag::LuauExplicitTypeExpressionInstantiation);
834+
LUAU_ASSERT(FFlag::LuauExplicitTypeInstantiationSyntax);
835835

836836
visualize(*a->expr);
837837

@@ -1892,7 +1892,7 @@ struct Printer
18921892

18931893
void visualizeExplicitTypeInstantiation(const AstArray<AstTypeOrPack>& typeArguments, const CstTypeInstantiation* cstNode)
18941894
{
1895-
LUAU_ASSERT(FFlag::LuauExplicitTypeExpressionInstantiation);
1895+
LUAU_ASSERT(FFlag::LuauExplicitTypeInstantiationSyntax);
18961896

18971897
if (cstNode)
18981898
{

luau/CodeGen/include/Luau/AssemblyBuilderA64.h

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,20 @@ class AssemblyBuilderA64
4444
void sub(RegisterA64 dst, RegisterA64 src1, uint16_t src2);
4545
void neg(RegisterA64 dst, RegisterA64 src);
4646

47+
// Prevent implicit conversions from happening
48+
template<typename T>
49+
void add(RegisterA64 dst, RegisterA64 src1, T src2) = delete;
50+
template<typename T>
51+
void sub(RegisterA64 dst, RegisterA64 src1, T src2) = delete;
52+
4753
// Comparisons
4854
// Note: some arithmetic instructions also have versions that update flags (ADDS etc) but we aren't using them atm
4955
void cmp(RegisterA64 src1, RegisterA64 src2);
5056
void cmp(RegisterA64 src1, uint16_t src2);
57+
58+
template<typename T>
59+
void cmp(RegisterA64 src1, T src2) = delete; // Prevent implicit conversions from happening
60+
5161
void csel(RegisterA64 dst, RegisterA64 src1, RegisterA64 src2, ConditionA64 cond);
5262
void cset(RegisterA64 dst, ConditionA64 cond);
5363

@@ -121,15 +131,23 @@ class AssemblyBuilderA64
121131
// Address of embedded data
122132
void adr(RegisterA64 dst, const void* ptr, size_t size);
123133
void adr(RegisterA64 dst, uint64_t value);
134+
void adr(RegisterA64 dst, float value);
124135
void adr(RegisterA64 dst, double value);
125136

137+
template<typename T>
138+
void adr(RegisterA64 dst, T value) = delete; // Prevent implicit conversions from happening
139+
126140
// Address of code (label)
127141
void adr(RegisterA64 dst, Label& label);
128142

129143
// Floating-point scalar/vector moves
130-
// Note: constant must be compatible with immediate floating point moves (see isFmovSupported)
144+
// Note: constant must be compatible with immediate floating point moves (see isFmovSupportedFp64/isFmovSupportedFp32)
131145
void fmov(RegisterA64 dst, RegisterA64 src);
132146
void fmov(RegisterA64 dst, double src);
147+
void fmov(RegisterA64 dst, float src);
148+
149+
template<typename T>
150+
void fmov(RegisterA64 dst, T src) = delete; // Prevent implicit conversions from happening
133151

134152
// Floating-point scalar/vector math
135153
void fabs(RegisterA64 dst, RegisterA64 src);
@@ -146,6 +164,7 @@ class AssemblyBuilderA64
146164
void ins_4s(RegisterA64 dst, RegisterA64 src, uint8_t index);
147165
void ins_4s(RegisterA64 dst, uint8_t dstIndex, RegisterA64 src, uint8_t srcIndex);
148166
void dup_4s(RegisterA64 dst, RegisterA64 src, uint8_t index);
167+
void umov_4s(RegisterA64 dst, RegisterA64 src, uint8_t index);
149168

150169
void fcmeq_4s(RegisterA64 dst, RegisterA64 src1, RegisterA64 src2);
151170
void bit(RegisterA64 dst, RegisterA64 src, RegisterA64 mask);
@@ -189,6 +208,7 @@ class AssemblyBuilderA64
189208

190209
void logAppend(const char* fmt, ...) LUAU_PRINTF_ATTR(2, 3);
191210

211+
// Code size is measured in 'code' array units - uint8_t on x64 and uint32_t on arm64
192212
uint32_t getCodeSize() const;
193213

194214
unsigned getInstructionCount() const;
@@ -210,7 +230,8 @@ class AssemblyBuilderA64
210230
static bool isMaskSupported(uint32_t mask);
211231

212232
// Check if fmov can be used to synthesize a constant
213-
static bool isFmovSupported(double value);
233+
static bool isFmovSupportedFp64(double value);
234+
static bool isFmovSupportedFp32(float value);
214235

215236
private:
216237
// Instruction archetypes

0 commit comments

Comments
 (0)