Skip to content

Commit

Permalink
fflag gate
Browse files Browse the repository at this point in the history
  • Loading branch information
checkraisefold committed Oct 30, 2024
1 parent ebaa850 commit bb825ad
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 12 deletions.
13 changes: 10 additions & 3 deletions Analysis/src/ConstraintGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ LUAU_DYNAMIC_FASTINT(LuauTypeSolverRelease)
LUAU_FASTFLAG(LuauTypestateBuiltins)

LUAU_FASTFLAGVARIABLE(LuauNewSolverVisitErrorExprLvalues, false)
LUAU_FASTFLAGVARIABLE(LuauNewSolverPopulateTableLocations, false)

namespace Luau
{
Expand Down Expand Up @@ -2844,7 +2845,10 @@ Inference ConstraintGenerator::check(const ScopePtr& scope, AstExprTable* expr,

ttv->state = TableState::Unsealed;
ttv->definitionModuleName = module->name;
ttv->definitionLocation = expr->location;
if (FFlag::LuauNewSolverPopulateTableLocations)
{
ttv->definitionLocation = expr->location;
}
ttv->scope = scope.get();

interiorTypes.back().push_back(ty);
Expand Down Expand Up @@ -3305,8 +3309,11 @@ TypeId ConstraintGenerator::resolveTableType(const ScopePtr& scope, AstType* ty,
TypeId tableTy = arena->addType(TableType{props, indexer, scope->level, scope.get(), TableState::Sealed});
TableType* ttv = getMutable<TableType>(tableTy);

ttv->definitionModuleName = module->name;
ttv->definitionLocation = tab->location;
if (FFlag::LuauNewSolverPopulateTableLocations)
{
ttv->definitionModuleName = module->name;
ttv->definitionLocation = tab->location;
}

return tableTy;
}
Expand Down
3 changes: 2 additions & 1 deletion Analysis/src/ConstraintSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ LUAU_FASTFLAGVARIABLE(DebugLuauLogBindings, false)
LUAU_FASTINTVARIABLE(LuauSolverRecursionLimit, 500)
LUAU_DYNAMIC_FASTINT(LuauTypeSolverRelease)
LUAU_FASTFLAGVARIABLE(LuauRemoveNotAnyHack, false)
LUAU_FASTFLAG(LuauNewSolverPopulateTableLocations)

namespace Luau
{
Expand Down Expand Up @@ -1108,7 +1109,7 @@ bool ConstraintSolver::tryDispatch(const TypeAliasExpansionConstraint& c, NotNul

target = follow(instantiated);
}
else
else if (FFlag::LuauNewSolverPopulateTableLocations)
{
// This is a new type - redefine the location.
ttv->definitionLocation = constraint->location;
Expand Down
27 changes: 19 additions & 8 deletions tests/TypeInfer.modules.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
LUAU_FASTFLAG(LuauInstantiateInSubtyping)
LUAU_FASTFLAG(LuauSolverV2)
LUAU_FASTFLAG(LuauTypestateBuiltins)
LUAU_FASTFLAG(LuauNewSolverPopulateTableLocations)

using namespace Luau;

Expand Down Expand Up @@ -465,10 +466,15 @@ local b: B.T = a
LUAU_REQUIRE_ERROR_COUNT(1, result);

if (FFlag::LuauSolverV2)
CHECK(
toString(result.errors.at(0)) ==
"Type 'T' from 'game/A' could not be converted into 'T' from 'game/B'; at [read \"x\"], number is not exactly string"
);
{
if (FFlag::LuauNewSolverPopulateTableLocations)
CHECK(
toString(result.errors.at(0)) ==
"Type 'T' from 'game/A' could not be converted into 'T' from 'game/B'; at [read \"x\"], number is not exactly string"
);
else
CHECK(toString(result.errors.at(0)) == "Type 'T' could not be converted into 'T'; at [read \"x\"], number is not exactly string");
}
else
{
const std::string expected = R"(Type 'T' from 'game/A' could not be converted into 'T' from 'game/B'
Expand Down Expand Up @@ -509,10 +515,15 @@ local b: B.T = a
LUAU_REQUIRE_ERROR_COUNT(1, result);

if (FFlag::LuauSolverV2)
CHECK(
toString(result.errors.at(0)) ==
"Type 'T' from 'game/B' could not be converted into 'T' from 'game/C'; at [read \"x\"], number is not exactly string"
);
{
if (FFlag::LuauNewSolverPopulateTableLocations)
CHECK(
toString(result.errors.at(0)) ==
"Type 'T' from 'game/B' could not be converted into 'T' from 'game/C'; at [read \"x\"], number is not exactly string"
);
else
CHECK(toString(result.errors.at(0)) == "Type 'T' could not be converted into 'T'; at [read \"x\"], number is not exactly string");
}
else
{
const std::string expected = R"(Type 'T' from 'game/B' could not be converted into 'T' from 'game/C'
Expand Down

0 comments on commit bb825ad

Please sign in to comment.