|
31 | 31 | LUAU_FASTINT(LuauCheckRecursionLimit)
|
32 | 32 | LUAU_FASTFLAG(DebugLuauLogSolverToJson)
|
33 | 33 | LUAU_FASTFLAG(DebugLuauMagicTypes)
|
34 |
| -LUAU_FASTFLAG(DebugLuauEqSatSimplification) |
35 | 34 | LUAU_FASTFLAG(LuauTypestateBuiltins2)
|
36 | 35 | LUAU_FASTFLAG(LuauUserTypeFunUpdateAllEnvs)
|
37 | 36 |
|
38 | 37 | LUAU_FASTFLAGVARIABLE(LuauNewSolverVisitErrorExprLvalues)
|
39 |
| -LUAU_FASTFLAGVARIABLE(LuauNewSolverPrePopulateClasses) |
40 | 38 | LUAU_FASTFLAGVARIABLE(LuauUserTypeFunExportedAndLocal)
|
| 39 | +LUAU_FASTFLAGVARIABLE(LuauNewSolverPrePopulateClasses) |
41 | 40 | LUAU_FASTFLAGVARIABLE(LuauNewSolverPopulateTableLocations)
|
42 | 41 | LUAU_FASTFLAGVARIABLE(LuauUserTypeFunNoExtraConstraint)
|
| 42 | +LUAU_FASTFLAGVARIABLE(LuauTrackInteriorFreeTypesOnScope) |
43 | 43 |
|
44 | 44 | LUAU_FASTFLAGVARIABLE(InferGlobalTypes)
|
45 | 45 |
|
@@ -233,8 +233,17 @@ void ConstraintGenerator::visitModuleRoot(AstStatBlock* block)
|
233 | 233 | Checkpoint end = checkpoint(this);
|
234 | 234 |
|
235 | 235 | TypeId result = arena->addType(BlockedType{});
|
236 |
| - NotNull<Constraint> genConstraint = |
237 |
| - addConstraint(scope, block->location, GeneralizationConstraint{result, moduleFnTy, std::move(interiorTypes.back())}); |
| 236 | + NotNull<Constraint> genConstraint = addConstraint( |
| 237 | + scope, |
| 238 | + block->location, |
| 239 | + GeneralizationConstraint{ |
| 240 | + result, moduleFnTy, FFlag::LuauTrackInteriorFreeTypesOnScope ? std::vector<TypeId>{} : std::move(interiorTypes.back()) |
| 241 | + } |
| 242 | + ); |
| 243 | + |
| 244 | + if (FFlag::LuauTrackInteriorFreeTypesOnScope) |
| 245 | + scope->interiorFreeTypes = std::move(interiorTypes.back()); |
| 246 | + |
238 | 247 | getMutable<BlockedType>(result)->setOwner(genConstraint);
|
239 | 248 | forEachConstraint(
|
240 | 249 | start,
|
@@ -303,9 +312,19 @@ void ConstraintGenerator::visitFragmentRoot(const ScopePtr& resumeScope, AstStat
|
303 | 312 | }
|
304 | 313 | }
|
305 | 314 |
|
| 315 | + |
306 | 316 | TypeId ConstraintGenerator::freshType(const ScopePtr& scope)
|
307 | 317 | {
|
308 |
| - return Luau::freshType(arena, builtinTypes, scope.get()); |
| 318 | + if (FFlag::LuauTrackInteriorFreeTypesOnScope) |
| 319 | + { |
| 320 | + auto ft = Luau::freshType(arena, builtinTypes, scope.get()); |
| 321 | + interiorTypes.back().push_back(ft); |
| 322 | + return ft; |
| 323 | + } |
| 324 | + else |
| 325 | + { |
| 326 | + return Luau::freshType(arena, builtinTypes, scope.get()); |
| 327 | + } |
309 | 328 | }
|
310 | 329 |
|
311 | 330 | TypePackId ConstraintGenerator::freshTypePack(const ScopePtr& scope)
|
@@ -2408,8 +2427,17 @@ Inference ConstraintGenerator::check(const ScopePtr& scope, AstExprFunction* fun
|
2408 | 2427 | Checkpoint endCheckpoint = checkpoint(this);
|
2409 | 2428 |
|
2410 | 2429 | TypeId generalizedTy = arena->addType(BlockedType{});
|
2411 |
| - NotNull<Constraint> gc = |
2412 |
| - addConstraint(sig.signatureScope, func->location, GeneralizationConstraint{generalizedTy, sig.signature, std::move(interiorTypes.back())}); |
| 2430 | + NotNull<Constraint> gc = addConstraint( |
| 2431 | + sig.signatureScope, |
| 2432 | + func->location, |
| 2433 | + GeneralizationConstraint{ |
| 2434 | + generalizedTy, sig.signature, FFlag::LuauTrackInteriorFreeTypesOnScope ? std::vector<TypeId>{} : std::move(interiorTypes.back()) |
| 2435 | + } |
| 2436 | + ); |
| 2437 | + |
| 2438 | + if (FFlag::LuauTrackInteriorFreeTypesOnScope) |
| 2439 | + sig.signatureScope->interiorFreeTypes = std::move(interiorTypes.back()); |
| 2440 | + |
2413 | 2441 | getMutable<BlockedType>(generalizedTy)->setOwner(gc);
|
2414 | 2442 | interiorTypes.pop_back();
|
2415 | 2443 |
|
@@ -2975,11 +3003,11 @@ Inference ConstraintGenerator::check(const ScopePtr& scope, AstExprTable* expr,
|
2975 | 3003 | ty,
|
2976 | 3004 | expr,
|
2977 | 3005 | toBlock
|
2978 |
| - ); |
2979 |
| - // The visitor we ran prior should ensure that there are no |
2980 |
| - // blocked types that we would encounter while matching on |
2981 |
| - // this expression. |
2982 |
| - LUAU_ASSERT(toBlock.empty()); |
| 3006 | + ); |
| 3007 | + // The visitor we ran prior should ensure that there are no |
| 3008 | + // blocked types that we would encounter while matching on |
| 3009 | + // this expression. |
| 3010 | + LUAU_ASSERT(toBlock.empty()); |
2983 | 3011 | }
|
2984 | 3012 | }
|
2985 | 3013 |
|
@@ -3941,20 +3969,7 @@ TypeId ConstraintGenerator::createTypeFunctionInstance(
|
3941 | 3969 |
|
3942 | 3970 | TypeId ConstraintGenerator::simplifyUnion(const ScopePtr& scope, Location location, TypeId left, TypeId right)
|
3943 | 3971 | {
|
3944 |
| - if (FFlag::DebugLuauEqSatSimplification) |
3945 |
| - { |
3946 |
| - TypeId ty = arena->addType(UnionType{{left, right}}); |
3947 |
| - std::optional<EqSatSimplificationResult> res = eqSatSimplify(simplifier, ty); |
3948 |
| - if (!res) |
3949 |
| - return ty; |
3950 |
| - |
3951 |
| - for (TypeId tyFun : res->newTypeFunctions) |
3952 |
| - addConstraint(scope, location, ReduceConstraint{tyFun}); |
3953 |
| - |
3954 |
| - return res->result; |
3955 |
| - } |
3956 |
| - else |
3957 |
| - return ::Luau::simplifyUnion(builtinTypes, arena, left, right).result; |
| 3972 | + return ::Luau::simplifyUnion(builtinTypes, arena, left, right).result; |
3958 | 3973 | }
|
3959 | 3974 |
|
3960 | 3975 | std::vector<NotNull<Constraint>> borrowConstraints(const std::vector<ConstraintPtr>& constraints)
|
|
0 commit comments