Skip to content

Commit

Permalink
Fix definition module name & location
Browse files Browse the repository at this point in the history
  • Loading branch information
checkraisefold committed Oct 28, 2024
1 parent db80939 commit bad96ac
Show file tree
Hide file tree
Showing 2 changed files with 14 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 @@ -2844,6 +2844,7 @@ Inference ConstraintGenerator::check(const ScopePtr& scope, AstExprTable* expr,

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

interiorTypes.back().push_back(ty);
Expand Down Expand Up @@ -2913,7 +2914,7 @@ Inference ConstraintGenerator::check(const ScopePtr& scope, AstExprTable* expr,
std::vector<TypeId> toBlock;
if (DFInt::LuauTypeSolverRelease >= 648)
{
// This logic is incomplete as we want to re-run this
// This logic is incomplete as we want to re-run this
// _after_ blocked types have resolved, but this
// allows us to do some bidirectional inference.
toBlock = findBlockedTypesIn(expr, NotNull{&module->astTypes});
Expand All @@ -2931,7 +2932,7 @@ Inference ConstraintGenerator::check(const ScopePtr& scope, AstExprTable* expr,
toBlock
);
// The visitor we ran prior should ensure that there are no
// blocked types that we would encounter while matching on
// blocked types that we would encounter while matching on
// this expression.
LUAU_ASSERT(toBlock.empty());
}
Expand Down Expand Up @@ -3301,7 +3302,13 @@ TypeId ConstraintGenerator::resolveTableType(const ScopePtr& scope, AstType* ty,
ice->ice("Unexpected property access " + std::to_string(int(astIndexer->access)));
}

return arena->addType(TableType{props, indexer, scope->level, scope.get(), TableState::Sealed});
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;

return tableTy;
}

TypeId ConstraintGenerator::resolveFunctionType(
Expand Down
13 changes: 4 additions & 9 deletions Analysis/src/ConstraintSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1111,7 +1111,6 @@ bool ConstraintSolver::tryDispatch(const TypeAliasExpansionConstraint& c, NotNul

ttv->instantiatedTypeParams = typeArguments;
ttv->instantiatedTypePackParams = packArguments;
// TODO: Fill in definitionModuleName.
}

bindResult(target);
Expand Down Expand Up @@ -1337,7 +1336,7 @@ bool ConstraintSolver::tryDispatch(const FunctionCheckConstraint& c, NotNull<con
{
// This is expensive as we need to traverse a (potentially large)
// literal up front in order to determine if there are any blocked
// types, otherwise we may run `matchTypeLiteral` multiple times,
// types, otherwise we may run `matchTypeLiteral` multiple times,
// which right now may fail due to being non-idempotent (it
// destructively updates the underlying literal type).
auto blockedTypes = findBlockedArgTypesIn(c.callSite, c.astTypes);
Expand Down Expand Up @@ -1433,7 +1432,8 @@ bool ConstraintSolver::tryDispatch(const FunctionCheckConstraint& c, NotNull<con
}
}
}
else if (expr->is<AstExprConstantBool>() || expr->is<AstExprConstantString>() || expr->is<AstExprConstantNumber>() || expr->is<AstExprConstantNil>())
else if (expr->is<AstExprConstantBool>() || expr->is<AstExprConstantString>() || expr->is<AstExprConstantNumber>() ||
expr->is<AstExprConstantNil>())
{
Unifier2 u2{arena, builtinTypes, constraint->scope, NotNull{&iceReporter}};
u2.unify(actualArgTy, expectedArgTy);
Expand Down Expand Up @@ -2326,12 +2326,7 @@ bool ConstraintSolver::tryDispatchIterableTable(TypeId iteratorTy, const Iterabl
return true;
}

bool ConstraintSolver::tryDispatchIterableFunction(
TypeId nextTy,
TypeId tableTy,
const IterableConstraint& c,
NotNull<const Constraint> constraint
)
bool ConstraintSolver::tryDispatchIterableFunction(TypeId nextTy, TypeId tableTy, const IterableConstraint& c, NotNull<const Constraint> constraint)
{
const FunctionType* nextFn = get<FunctionType>(nextTy);
// If this does not hold, we should've never called `tryDispatchIterableFunction` in the first place.
Expand Down

0 comments on commit bad96ac

Please sign in to comment.