Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync to upstream/release/639 #1368

Merged
merged 136 commits into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
136 commits
Select commit Hold shift + click to select a range
a0b9950
Sync to upstream/release/602
aatxe Nov 3, 2023
efe133a
Merge branch 'upstream' into merge
aatxe Nov 3, 2023
4b68791
Sync to upstream/release/603
alexmccord Nov 10, 2023
6343648
Merge branch 'master' into merge
alexmccord Nov 10, 2023
e57cbf6
Merge branch 'heads/upstream' into merge
alexmccord Nov 10, 2023
674c6c4
Sync to upstream/release/604
andyfriesen Nov 17, 2023
4320153
Merge branch 'master' into merge
andyfriesen Nov 17, 2023
2d4a544
Merge branch 'upstream' into merge
andyfriesen Nov 17, 2023
557e77a
VM
Vighnesh-V Dec 2, 2023
98d2db7
add stdint import
Vighnesh-V Dec 2, 2023
e70eec0
Merge branch 'upstream' into merge
Vighnesh-V Dec 2, 2023
7985414
resolve one last merge conflict
Vighnesh-V Dec 2, 2023
c592f50
can CI handle this?
Vighnesh-V Dec 2, 2023
41669c9
Sync to upstream/release/605
Vighnesh-V Dec 2, 2023
c932b8e
remove tests for require by string
Vighnesh-V Dec 2, 2023
c48ffc3
endif
Vighnesh-V Dec 2, 2023
69728e8
Sync to upstream/release/606
vegorov-rbx Dec 8, 2023
f5441d7
Merge branch 'master' into merge
vegorov-rbx Dec 8, 2023
6068432
Merge branch 'upstream' into merge
vegorov-rbx Dec 8, 2023
139b169
Merge fix
vegorov-rbx Dec 8, 2023
f9c5cdd
Sync to upstream/release/607
aatxe Dec 15, 2023
89090a1
Merge branch 'master' into merge
aatxe Dec 15, 2023
d622618
Merge branch 'upstream' into merge
aatxe Dec 15, 2023
adea0f8
fix ubuntu build with import for cstddef in DenseHash
aatxe Dec 15, 2023
d4883bf
Merge branch 'upstream' of https://github.com/luau-lang/luau into ups…
Vighnesh-V Jan 11, 2024
0d5c842
Sync to upstream/release/608
Vighnesh-V Jan 12, 2024
74b0d00
Merge branch 'master' into merge
Vighnesh-V Jan 12, 2024
7932835
Merge branch 'upstream' into merge
Vighnesh-V Jan 12, 2024
50b4779
Sync to upstream/release/608
Vighnesh-V Jan 12, 2024
2f7509d
Merge branch 'upstream' into merge
Vighnesh-V Jan 12, 2024
38aa074
resolve memory leak in VecDeque
Vighnesh-V Jan 12, 2024
064d845
Sync to upstream/release/609
vegorov-rbx Jan 19, 2024
59a29fd
Merge branch 'master' into merge
vegorov-rbx Jan 19, 2024
2fd3da3
Merge branch 'upstream' into merge
vegorov-rbx Jan 19, 2024
0edacdd
Sync to upstream/release/610
aatxe Jan 27, 2024
e3aba92
Merge branch 'master' into merge
aatxe Jan 27, 2024
ce2665d
Merge branch 'upstream' into merge
aatxe Jan 27, 2024
dfa512b
Sync to upstream/release/611
alexmccord Feb 2, 2024
f8f0dd9
Merge branch 'master' into merge
alexmccord Feb 2, 2024
88d2b93
Merge branch 'heads/upstream' into merge
alexmccord Feb 2, 2024
5559c7f
Fix the stack-use-after-scope.
alexmccord Feb 2, 2024
1a6da94
Sync to upstream/release/612
andyfriesen Feb 9, 2024
45e72ee
Merge branch 'master' into merge
andyfriesen Feb 9, 2024
ffd9f32
Merge branch 'upstream' into merge
andyfriesen Feb 9, 2024
158d60c
Sync to upstream/release/613
vegorov-rbx Feb 16, 2024
1778950
Merge branch 'master' into merge
vegorov-rbx Feb 16, 2024
b5f2813
Merge branch 'upstream' into merge
vegorov-rbx Feb 16, 2024
22686ef
Sync to upstream/release/614
Vighnesh-V Feb 23, 2024
ccb5385
Merge branch 'master' into merge
Vighnesh-V Feb 23, 2024
0ab33af
Merge branch 'upstream' into merge
Vighnesh-V Feb 23, 2024
d4a2665
Sync to upstream/release/615
vegorov-rbx Mar 1, 2024
532fd10
Merge branch 'master' into merge
vegorov-rbx Mar 1, 2024
f36cae2
Merge branch 'upstream' into merge
vegorov-rbx Mar 1, 2024
ed4ce84
Merge fixes
vegorov-rbx Mar 1, 2024
27a05c0
Sync to upstream/release/616
aatxe Mar 8, 2024
9e1a26c
Merge branch 'master' into merge
aatxe Mar 8, 2024
1ebdfe0
Merge branch 'upstream' into merge
aatxe Mar 9, 2024
f27d4f5
Sync to upstream/release/617
alexmccord Mar 15, 2024
5e9a567
Merge branch 'master' into merge
alexmccord Mar 15, 2024
c1bbf1e
Merge branch 'heads/upstream' into merge
alexmccord Mar 15, 2024
6fff08b
Sync to upstream/release/618
andyfriesen Mar 22, 2024
a30b2ae
Merge branch 'master' into merge
andyfriesen Mar 22, 2024
4931165
Merge branch 'upstream' into merge
andyfriesen Mar 22, 2024
d8f49d6
Compiler fixes for MSVC and GCC.
andyfriesen Mar 22, 2024
fb90dc0
Sync with upstream/release/620
AmaranthineCodices Mar 30, 2024
77598ed
Merge branch 'master' into merge
AmaranthineCodices Mar 30, 2024
3e1b413
Merge branch 'upstream' into merge
AmaranthineCodices Mar 30, 2024
c730a51
Sync to upstream/release/620
Vighnesh-V Apr 5, 2024
6bef0b1
Merge branch 'master' into merge
Vighnesh-V Apr 5, 2024
2e1c040
Merge branch 'upstream' into merge
Vighnesh-V Apr 5, 2024
9cb93a9
manually fix cmake configuration error
Vighnesh-V Apr 5, 2024
0f19739
remove trailing .
Vighnesh-V Apr 5, 2024
5aa6d99
transplant game engine fix for memory safety issues in normalization …
Vighnesh-V Apr 5, 2024
0f0c0e4
Sync to upstream/release/621
vegorov-rbx Apr 12, 2024
7c346a0
Merge branch 'master' into merge
vegorov-rbx Apr 12, 2024
f97e96d
Merge branch 'upstream' into merge
vegorov-rbx Apr 12, 2024
858b93a
Sync fixup
vegorov-rbx Apr 12, 2024
67b9145
Sync to upstream/release/622
aatxe Apr 19, 2024
5cf508a
Merge branch 'master' into merge
aatxe Apr 19, 2024
641e9f6
Merge branch 'upstream' into merge
aatxe Apr 19, 2024
50a2f8d
Sync to upstream/release/623
alexmccord Apr 25, 2024
8d0a650
Merge branch 'master' into merge
alexmccord Apr 25, 2024
76ed1a5
Merge branch 'heads/upstream' into merge
alexmccord Apr 25, 2024
88dd289
Fix missing include.
alexmccord Apr 25, 2024
93468ca
Sync to upstream/release/624
andyfriesen May 3, 2024
f4ecf43
Merge branch 'master' into merge
andyfriesen May 3, 2024
1ad7b9c
Merge branch 'upstream' into merge
andyfriesen May 3, 2024
9bce20c
Sync to upstream/release/625
Vighnesh-V May 10, 2024
f76a99b
Merge branch 'master' into merge
Vighnesh-V May 10, 2024
f172471
Merge branch 'upstream' into merge
Vighnesh-V May 10, 2024
0386eec
Sync to upstream/release/626
vegorov-rbx May 16, 2024
e5de2ed
Merge branch 'master' into merge
vegorov-rbx May 16, 2024
ca46dd6
Merge branch 'upstream' into merge
vegorov-rbx May 16, 2024
0f61e4e
Merge fix
vegorov-rbx May 16, 2024
bad9e14
627
aatxe May 26, 2024
26fb155
Merge branch 'master' into merge
aatxe May 26, 2024
241fcf8
Merge branch 'upstream' into merge
aatxe May 26, 2024
fede4d6
Sync to upstream/release/628
alexmccord May 31, 2024
09e46d1
Merge branch 'master' into merge
alexmccord May 31, 2024
93a89dc
Merge branch 'heads/upstream' into merge
alexmccord May 31, 2024
5dd9735
Sync to upstream/release/629
andyfriesen Jun 7, 2024
eae092a
Merge branch 'master' into merge
andyfriesen Jun 7, 2024
40e0316
Merge branch 'upstream' into merge
andyfriesen Jun 7, 2024
58b9809
Sync to upstream/release/630
Vighnesh-V Jun 14, 2024
91790ef
Merge branch 'master' into merge
Vighnesh-V Jun 14, 2024
2a1359d
Merge branch 'upstream' into merge
Vighnesh-V Jun 14, 2024
1ba3e5f
correct the flag name
Vighnesh-V Jun 14, 2024
816cb1d
Sync to upstream/release/631
vegorov-rbx Jun 20, 2024
5d2e3de
Merge branch 'master' into merge
vegorov-rbx Jun 20, 2024
dafb44d
Merge branch 'upstream' into merge
vegorov-rbx Jun 20, 2024
240a9d8
Sync to upstream/release/632
aatxe Jun 29, 2024
c5a2a4b
Merge branch 'master' into merge
aatxe Jun 29, 2024
da48758
Merge branch 'upstream' into merge
aatxe Jun 29, 2024
cfcb545
Sync to upstream/release/633
Vighnesh-V Jul 8, 2024
2010be1
Merge branch 'master' into merge
Vighnesh-V Jul 8, 2024
bc1bead
Merge branch 'upstream' into merge
Vighnesh-V Jul 8, 2024
1c1476f
Sync to upstream/release/634
joonyoo181 Jul 11, 2024
a62f661
Merge branch 'master' into merge
joonyoo181 Jul 11, 2024
5a23350
Merge branch 'upstream' into merge
joonyoo181 Jul 11, 2024
6fd26c5
Sync to upstream/release/635
Vighnesh-V Jul 19, 2024
79966e9
Merge branch 'master' into merge
Vighnesh-V Jul 19, 2024
ac97a49
Merge branch 'upstream' into merge
Vighnesh-V Jul 19, 2024
7dd10b1
Sync to upstream/release/636
joonyoo181 Jul 26, 2024
fab4eec
Merge branch 'master' into merge
joonyoo181 Jul 26, 2024
48c0e9f
Merge branch 'upstream' into merge
joonyoo181 Jul 26, 2024
bb7d5cf
StudioReportLuauAny added to ExperimentalFlags
joonyoo181 Jul 26, 2024
28c48cf
Skip StudioReportLuauAny flag in tests
joonyoo181 Jul 26, 2024
fad8aaf
Sync to upstream/release/637
joonyoo181 Aug 1, 2024
5b40152
Merge branch 'master' into merge
joonyoo181 Aug 1, 2024
1adbd45
Merge branch 'upstream' into merge
joonyoo181 Aug 1, 2024
8a99f25
Sync to upstream/release/638
andyfriesen Aug 9, 2024
057bdf3
Merge branch 'master' into merge
andyfriesen Aug 9, 2024
c229a9e
Merge branch 'upstream' into merge
andyfriesen Aug 9, 2024
497c3ed
Sync to upstream/release/639
Vighnesh-V Aug 16, 2024
8c4f907
Merge branch 'master' into merge
Vighnesh-V Aug 16, 2024
3613ee9
Merge branch 'upstream' into merge
Vighnesh-V Aug 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 7 additions & 26 deletions Analysis/src/AstJsonEncoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@

#include <math.h>

LUAU_FASTFLAG(LuauDeclarationExtraPropData)

namespace Luau
{

Expand Down Expand Up @@ -898,19 +896,11 @@ struct AstJsonEncoder : public AstVisitor
{
// TODO: attributes
PROP(name);

if (FFlag::LuauDeclarationExtraPropData)
PROP(nameLocation);

PROP(nameLocation);
PROP(params);

if (FFlag::LuauDeclarationExtraPropData)
{
PROP(paramNames);
PROP(vararg);
PROP(varargLocation);
}

PROP(paramNames);
PROP(vararg);
PROP(varargLocation);
PROP(retTypes);
PROP(generics);
PROP(genericPacks);
Expand All @@ -926,10 +916,7 @@ struct AstJsonEncoder : public AstVisitor
[&]()
{
PROP(name);

if (FFlag::LuauDeclarationExtraPropData)
PROP(nameLocation);

PROP(nameLocation);
PROP(type);
}
);
Expand All @@ -940,16 +927,10 @@ struct AstJsonEncoder : public AstVisitor
writeRaw("{");
bool c = pushComma();
write("name", prop.name);

if (FFlag::LuauDeclarationExtraPropData)
write("nameLocation", prop.nameLocation);

write("nameLocation", prop.nameLocation);
writeType("AstDeclaredClassProp");
write("luauType", prop.ty);

if (FFlag::LuauDeclarationExtraPropData)
write("location", prop.location);

write("location", prop.location);
popComma(c);
writeRaw("}");
}
Expand Down
22 changes: 19 additions & 3 deletions Analysis/src/BuiltinDefinitions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -374,9 +374,25 @@ void registerBuiltinGlobals(Frontend& frontend, GlobalTypes& globals, bool typeC

if (TableType* ttv = getMutable<TableType>(getGlobalBinding(globals, "table")))
{
// tabTy is a generic table type which we can't express via declaration syntax yet
ttv->props["freeze"] = makeProperty(makeFunction(arena, std::nullopt, {tabTy}, {tabTy}), "@luau/global/table.freeze");
ttv->props["clone"] = makeProperty(makeFunction(arena, std::nullopt, {tabTy}, {tabTy}), "@luau/global/table.clone");
if (FFlag::DebugLuauDeferredConstraintResolution)
{
// CLI-114044 - The new solver does not yet support generic tables,
// which act, in an odd way, like generics that are constrained to
// the top table type. We do the best we can by modelling these
// functions using unconstrained generics. It's not quite right,
// but it'll be ok for now.
TypeId genericTy = arena.addType(GenericType{"T"});
TypePackId thePack = arena.addTypePack({genericTy});
TypeId idTy = arena.addType(FunctionType{{genericTy}, {}, thePack, thePack});
ttv->props["freeze"] = makeProperty(idTy, "@luau/global/table.freeze");
ttv->props["clone"] = makeProperty(idTy, "@luau/global/table.clone");
}
else
{
// tabTy is a generic table type which we can't express via declaration syntax yet
ttv->props["freeze"] = makeProperty(makeFunction(arena, std::nullopt, {tabTy}, {tabTy}), "@luau/global/table.freeze");
ttv->props["clone"] = makeProperty(makeFunction(arena, std::nullopt, {tabTy}, {tabTy}), "@luau/global/table.clone");
}

ttv->props["getn"].deprecated = true;
ttv->props["getn"].deprecatedSuggestion = "#";
Expand Down
143 changes: 75 additions & 68 deletions Analysis/src/ConstraintGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
LUAU_FASTINT(LuauCheckRecursionLimit);
LUAU_FASTFLAG(DebugLuauLogSolverToJson);
LUAU_FASTFLAG(DebugLuauMagicTypes);
LUAU_FASTFLAG(LuauDeclarationExtraPropData);

namespace Luau
{
Expand Down Expand Up @@ -550,6 +549,13 @@ bool mustDeferIntersection(TypeId ty)
}
} // namespace

enum RefinementsOpKind
{
Intersect,
Refine,
None
};

void ConstraintGenerator::applyRefinements(const ScopePtr& scope, Location location, RefinementId refinement)
{
if (!refinement)
Expand All @@ -558,6 +564,23 @@ void ConstraintGenerator::applyRefinements(const ScopePtr& scope, Location locat
RefinementContext refinements;
std::vector<ConstraintV> constraints;
computeRefinement(scope, location, refinement, &refinements, /*sense*/ true, /*eq*/ false, &constraints);
auto flushConstraints = [this, &scope, &location](RefinementsOpKind kind, TypeId ty, std::vector<TypeId>& discriminants)
{
if (discriminants.empty())
return ty;
if (kind == RefinementsOpKind::None)
{
LUAU_ASSERT(false);
return ty;
}
std::vector<TypeId> args = {ty};
const TypeFunction& func = kind == RefinementsOpKind::Intersect ? builtinTypeFunctions().intersectFunc : builtinTypeFunctions().refineFunc;
LUAU_ASSERT(!func.name.empty());
args.insert(args.end(), discriminants.begin(), discriminants.end());
TypeId resultType = createTypeFunctionInstance(func, args, {}, scope, location);
discriminants.clear();
return resultType;
};

for (auto& [def, partition] : refinements)
{
Expand All @@ -566,41 +589,52 @@ void ConstraintGenerator::applyRefinements(const ScopePtr& scope, Location locat
TypeId ty = *defTy;
if (partition.shouldAppendNilType)
ty = arena->addType(UnionType{{ty, builtinTypes->nilType}});

// Intersect ty with every discriminant type. If either type is not
// sufficiently solved, we queue the intersection up via an
// IntersectConstraint.

// For each discriminant ty, we accumulated it onto ty, creating a longer and longer
// sequence of refine constraints. On every loop of this we called mustDeferIntersection.
// For sufficiently large types, we would blow the stack.
// Instead, we record all the discriminant types in sequence
// and then dispatch a single refine constraint with multiple arguments. This helps us avoid
// the potentially expensive check on mustDeferIntersection
std::vector<TypeId> discriminants;
RefinementsOpKind kind = RefinementsOpKind::None;
bool mustDefer = mustDeferIntersection(ty);
for (TypeId dt : partition.discriminantTypes)
{
if (mustDeferIntersection(ty) || mustDeferIntersection(dt))
mustDefer = mustDefer || mustDeferIntersection(dt);
if (mustDefer)
{
TypeId resultType = createTypeFunctionInstance(builtinTypeFunctions().refineFunc, {ty, dt}, {}, scope, location);
if (kind == RefinementsOpKind::Intersect)
ty = flushConstraints(kind, ty, discriminants);
kind = RefinementsOpKind::Refine;

ty = resultType;
discriminants.push_back(dt);
}
else
{
switch (shouldSuppressErrors(normalizer, ty))
{
case ErrorSuppression::DoNotSuppress:
ErrorSuppression status = shouldSuppressErrors(normalizer, ty);
if (status == ErrorSuppression::NormalizationFailed)
reportError(location, NormalizationTooComplex{});
if (kind == RefinementsOpKind::Refine)
ty = flushConstraints(kind, ty, discriminants);
kind = RefinementsOpKind::Intersect;

discriminants.push_back(dt);

if (status == ErrorSuppression::Suppress)
{
if (!get<NeverType>(follow(ty)))
ty = makeIntersect(scope, location, ty, dt);
break;
}
case ErrorSuppression::Suppress:
ty = makeIntersect(scope, location, ty, dt);
ty = flushConstraints(kind, ty, discriminants);
ty = makeUnion(scope, location, ty, builtinTypes->errorType);
break;
case ErrorSuppression::NormalizationFailed:
reportError(location, NormalizationTooComplex{});
ty = makeIntersect(scope, location, ty, dt);
break;
}
}
}

// Finalize - if there are any discriminants left, make one big constraint for refining them
if (kind != RefinementsOpKind::None)
ty = flushConstraints(kind, ty, discriminants);

scope->rvalueRefinements[def] = ty;
}
}
Expand Down Expand Up @@ -1532,30 +1566,24 @@ ControlFlow ConstraintGenerator::visit(const ScopePtr& scope, AstStatDeclareClas

ftv->hasSelf = true;

if (FFlag::LuauDeclarationExtraPropData)
{
FunctionDefinition defn;
FunctionDefinition defn;

defn.definitionModuleName = module->name;
defn.definitionLocation = prop.location;
// No data is preserved for varargLocation
defn.originalNameLocation = prop.nameLocation;
defn.definitionModuleName = module->name;
defn.definitionLocation = prop.location;
// No data is preserved for varargLocation
defn.originalNameLocation = prop.nameLocation;

ftv->definition = defn;
}
ftv->definition = defn;
}
}

TableType::Props& props = assignToMetatable ? metatable->props : ctv->props;

if (props.count(propName) == 0)
{
if (FFlag::LuauDeclarationExtraPropData)
props[propName] = {propTy, /*deprecated*/ false, /*deprecatedSuggestion*/ "", prop.location};
else
props[propName] = {propTy};
props[propName] = {propTy, /*deprecated*/ false, /*deprecatedSuggestion*/ "", prop.location};
}
else if (FFlag::LuauDeclarationExtraPropData)
else
{
Luau::Property& prop = props[propName];
TypeId currentTy = prop.type();
Expand Down Expand Up @@ -1583,31 +1611,6 @@ ControlFlow ConstraintGenerator::visit(const ScopePtr& scope, AstStatDeclareClas
reportError(declaredClass->location, GenericError{format("Cannot overload non-function class member '%s'", propName.c_str())});
}
}
else
{
TypeId currentTy = props[propName].type();

// We special-case this logic to keep the intersection flat; otherwise we
// would create a ton of nested intersection types.
if (const IntersectionType* itv = get<IntersectionType>(currentTy))
{
std::vector<TypeId> options = itv->parts;
options.push_back(propTy);
TypeId newItv = arena->addType(IntersectionType{std::move(options)});

props[propName] = {newItv};
}
else if (get<FunctionType>(currentTy))
{
TypeId intersection = arena->addType(IntersectionType{{currentTy, propTy}});

props[propName] = {intersection};
}
else
{
reportError(declaredClass->location, GenericError{format("Cannot overload non-function class member '%s'", propName.c_str())});
}
}
}

return ControlFlow::None;
Expand Down Expand Up @@ -1641,13 +1644,10 @@ ControlFlow ConstraintGenerator::visit(const ScopePtr& scope, AstStatDeclareFunc

FunctionDefinition defn;

if (FFlag::LuauDeclarationExtraPropData)
{
defn.definitionModuleName = module->name;
defn.definitionLocation = global->location;
defn.varargLocation = global->vararg ? std::make_optional(global->varargLocation) : std::nullopt;
defn.originalNameLocation = global->nameLocation;
}
defn.definitionModuleName = module->name;
defn.definitionLocation = global->location;
defn.varargLocation = global->vararg ? std::make_optional(global->varargLocation) : std::nullopt;
defn.originalNameLocation = global->nameLocation;

TypeId fnType = arena->addType(FunctionType{TypeLevel{}, funScope.get(), std::move(genericTys), std::move(genericTps), paramPack, retPack, defn});
FunctionType* ftv = getMutable<FunctionType>(fnType);
Expand Down Expand Up @@ -1989,7 +1989,7 @@ Inference ConstraintGenerator::check(const ScopePtr& scope, AstExpr* expr, std::
Inference result;

if (auto group = expr->as<AstExprGroup>())
result = check(scope, group->expr, expectedType, forceSingleton);
result = check(scope, group->expr, expectedType, forceSingleton, generalize);
else if (auto stringExpr = expr->as<AstExprConstantString>())
result = check(scope, stringExpr, expectedType, forceSingleton);
else if (expr->is<AstExprConstantNumber>())
Expand Down Expand Up @@ -2188,6 +2188,7 @@ Inference ConstraintGenerator::check(const ScopePtr& scope, AstExprIndexExpr* in
{
if (auto constantString = indexExpr->index->as<AstExprConstantString>())
{
module->astTypes[indexExpr->index] = builtinTypes->stringType;
const RefinementKey* key = dfg->getRefinementKey(indexExpr);
return checkIndexName(scope, key, indexExpr->expr, constantString->value.data, indexExpr->location);
}
Expand Down Expand Up @@ -3005,7 +3006,13 @@ TypeId ConstraintGenerator::resolveType(const ScopePtr& scope, AstType* ty, bool
}
else if (p.typePack)
{
packParameters.push_back(resolveTypePack(scope, p.typePack, /* inTypeArguments */ true));
TypePackId tp = resolveTypePack(scope, p.typePack, /*inTypeArguments*/ true);

// If we need more regular types, we can use single element type packs to fill those in
if (parameters.size() < alias->typeParams.size() && size(tp) == 1 && finite(tp) && first(tp))
parameters.push_back(*first(tp));
else
packParameters.push_back(tp);
}
else
{
Expand Down
15 changes: 14 additions & 1 deletion Analysis/src/ConstraintSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1271,6 +1271,8 @@ bool ConstraintSolver::tryDispatch(const FunctionCallConstraint& c, NotNull<cons

if (occursCheckPassed && c.callSite)
(*c.astOverloadResolvedTypes)[c.callSite] = inferredTy;
else if (!occursCheckPassed)
reportError(OccursCheckFailed{}, constraint->location);

InstantiationQueuer queuer{constraint->scope, constraint->location, this};
queuer.traverse(overloadToUse);
Expand All @@ -1281,6 +1283,14 @@ bool ConstraintSolver::tryDispatch(const FunctionCallConstraint& c, NotNull<cons
return true;
}

static AstExpr* unwrapGroup(AstExpr* expr)
{
while (auto group = expr->as<AstExprGroup>())
expr = group->expr;

return expr;
}

bool ConstraintSolver::tryDispatch(const FunctionCheckConstraint& c, NotNull<const Constraint> constraint)
{
TypeId fn = follow(c.fn);
Expand Down Expand Up @@ -1354,7 +1364,7 @@ bool ConstraintSolver::tryDispatch(const FunctionCheckConstraint& c, NotNull<con
{
const TypeId expectedArgTy = follow(expectedArgs[i + typeOffset]);
const TypeId actualArgTy = follow(argPackHead[i + typeOffset]);
const AstExpr* expr = c.callSite->args.data[i];
const AstExpr* expr = unwrapGroup(c.callSite->args.data[i]);

(*c.astExpectedTypes)[expr] = expectedArgTy;

Expand Down Expand Up @@ -1697,7 +1707,10 @@ bool ConstraintSolver::tryDispatch(const AssignPropConstraint& c, NotNull<const
{
const Property* prop = lookupClassProp(lhsClass, propName);
if (!prop || !prop->writeTy.has_value())
{
bind(constraint, c.propType, builtinTypes->anyType);
return true;
}

bind(constraint, c.propType, *prop->writeTy);
unify(constraint, rhsType, *prop->writeTy);
Expand Down
Loading
Loading