Skip to content

Commit

Permalink
fix type alias expansion definition loc/module
Browse files Browse the repository at this point in the history
  • Loading branch information
checkraisefold committed Oct 29, 2024
1 parent bad96ac commit ebaa850
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
6 changes: 6 additions & 0 deletions Analysis/src/ConstraintSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1108,6 +1108,12 @@ bool ConstraintSolver::tryDispatch(const TypeAliasExpansionConstraint& c, NotNul

target = follow(instantiated);
}
else
{
// This is a new type - redefine the location.
ttv->definitionLocation = constraint->location;
ttv->definitionModuleName = currentModuleName;
}

ttv->instantiatedTypeParams = typeArguments;
ttv->instantiatedTypePackParams = packArguments;
Expand Down
10 changes: 8 additions & 2 deletions tests/TypeInfer.modules.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,10 @@ local b: B.T = a
LUAU_REQUIRE_ERROR_COUNT(1, result);

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

if (FFlag::LuauSolverV2)
CHECK(toString(result.errors.at(0)) == "Type 'T' could not be converted into 'T'; at [read \"x\"], number is not exactly string");
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
{
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 ebaa850

Please sign in to comment.