From bad96ac45fc5280a4fdc667b4a454fd6d4054901 Mon Sep 17 00:00:00 2001 From: checkraisefold <checkraisefold@crf.gay> Date: Sun, 27 Oct 2024 19:59:10 -0700 Subject: [PATCH] Fix definition module name & location --- Analysis/src/ConstraintGenerator.cpp | 13 ++++++++++--- Analysis/src/ConstraintSolver.cpp | 13 ++++--------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/Analysis/src/ConstraintGenerator.cpp b/Analysis/src/ConstraintGenerator.cpp index e242df8ec..9ff03fe43 100644 --- a/Analysis/src/ConstraintGenerator.cpp +++ b/Analysis/src/ConstraintGenerator.cpp @@ -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); @@ -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}); @@ -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()); } @@ -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( diff --git a/Analysis/src/ConstraintSolver.cpp b/Analysis/src/ConstraintSolver.cpp index 31afabb23..df1e48a30 100644 --- a/Analysis/src/ConstraintSolver.cpp +++ b/Analysis/src/ConstraintSolver.cpp @@ -1111,7 +1111,6 @@ bool ConstraintSolver::tryDispatch(const TypeAliasExpansionConstraint& c, NotNul ttv->instantiatedTypeParams = typeArguments; ttv->instantiatedTypePackParams = packArguments; - // TODO: Fill in definitionModuleName. } bindResult(target); @@ -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); @@ -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); @@ -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.