Skip to content

Commit d9865a5

Browse files
fflag gate
1 parent 4eedd23 commit d9865a5

File tree

3 files changed

+31
-12
lines changed

3 files changed

+31
-12
lines changed

Analysis/src/ConstraintGenerator.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ LUAU_DYNAMIC_FASTINT(LuauTypeSolverRelease)
3434
LUAU_FASTFLAG(LuauTypestateBuiltins2)
3535

3636
LUAU_FASTFLAGVARIABLE(LuauNewSolverVisitErrorExprLvalues)
37+
LUAU_FASTFLAGVARIABLE(LuauNewSolverPopulateTableLocations)
3738

3839
namespace Luau
3940
{
@@ -2844,7 +2845,10 @@ Inference ConstraintGenerator::check(const ScopePtr& scope, AstExprTable* expr,
28442845

28452846
ttv->state = TableState::Unsealed;
28462847
ttv->definitionModuleName = module->name;
2847-
ttv->definitionLocation = expr->location;
2848+
if (FFlag::LuauNewSolverPopulateTableLocations)
2849+
{
2850+
ttv->definitionLocation = expr->location;
2851+
}
28482852
ttv->scope = scope.get();
28492853

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

3308-
ttv->definitionModuleName = module->name;
3309-
ttv->definitionLocation = tab->location;
3312+
if (FFlag::LuauNewSolverPopulateTableLocations)
3313+
{
3314+
ttv->definitionModuleName = module->name;
3315+
ttv->definitionLocation = tab->location;
3316+
}
33103317

33113318
return tableTy;
33123319
}

Analysis/src/ConstraintSolver.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ LUAU_FASTFLAGVARIABLE(DebugLuauLogBindings)
3333
LUAU_FASTINTVARIABLE(LuauSolverRecursionLimit, 500)
3434
LUAU_DYNAMIC_FASTINT(LuauTypeSolverRelease)
3535
LUAU_FASTFLAGVARIABLE(LuauRemoveNotAnyHack)
36+
LUAU_FASTFLAG(LuauNewSolverPopulateTableLocations)
3637

3738
namespace Luau
3839
{
@@ -1108,7 +1109,7 @@ bool ConstraintSolver::tryDispatch(const TypeAliasExpansionConstraint& c, NotNul
11081109

11091110
target = follow(instantiated);
11101111
}
1111-
else
1112+
else if (FFlag::LuauNewSolverPopulateTableLocations)
11121113
{
11131114
// This is a new type - redefine the location.
11141115
ttv->definitionLocation = constraint->location;

tests/TypeInfer.modules.test.cpp

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ LUAU_FASTFLAG(LuauInstantiateInSubtyping)
1414
LUAU_FASTFLAG(LuauRequireCyclesDontAlwaysReturnAny)
1515
LUAU_FASTFLAG(LuauSolverV2)
1616
LUAU_FASTFLAG(LuauTypestateBuiltins2)
17+
LUAU_FASTFLAG(LuauNewSolverPopulateTableLocations)
1718

1819
using namespace Luau;
1920

@@ -466,10 +467,15 @@ local b: B.T = a
466467
LUAU_REQUIRE_ERROR_COUNT(1, result);
467468

468469
if (FFlag::LuauSolverV2)
469-
CHECK(
470-
toString(result.errors.at(0)) ==
471-
"Type 'T' from 'game/A' could not be converted into 'T' from 'game/B'; at [read \"x\"], number is not exactly string"
472-
);
470+
{
471+
if (FFlag::LuauNewSolverPopulateTableLocations)
472+
CHECK(
473+
toString(result.errors.at(0)) ==
474+
"Type 'T' from 'game/A' could not be converted into 'T' from 'game/B'; at [read \"x\"], number is not exactly string"
475+
);
476+
else
477+
CHECK(toString(result.errors.at(0)) == "Type 'T' could not be converted into 'T'; at [read \"x\"], number is not exactly string");
478+
}
473479
else
474480
{
475481
const std::string expected = R"(Type 'T' from 'game/A' could not be converted into 'T' from 'game/B'
@@ -510,10 +516,15 @@ local b: B.T = a
510516
LUAU_REQUIRE_ERROR_COUNT(1, result);
511517

512518
if (FFlag::LuauSolverV2)
513-
CHECK(
514-
toString(result.errors.at(0)) ==
515-
"Type 'T' from 'game/B' could not be converted into 'T' from 'game/C'; at [read \"x\"], number is not exactly string"
516-
);
519+
{
520+
if (FFlag::LuauNewSolverPopulateTableLocations)
521+
CHECK(
522+
toString(result.errors.at(0)) ==
523+
"Type 'T' from 'game/B' could not be converted into 'T' from 'game/C'; at [read \"x\"], number is not exactly string"
524+
);
525+
else
526+
CHECK(toString(result.errors.at(0)) == "Type 'T' could not be converted into 'T'; at [read \"x\"], number is not exactly string");
527+
}
517528
else
518529
{
519530
const std::string expected = R"(Type 'T' from 'game/B' could not be converted into 'T' from 'game/C'

0 commit comments

Comments
 (0)