Changeset b96b1c0
- Timestamp:
- Jun 16, 2023, 3:24:20 PM (17 months ago)
- Branches:
- master
- Children:
- 64727bd
- Parents:
- 3a7aa94
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/CandidateFinder.cpp
r3a7aa94 rb96b1c0 315 315 /// Instantiates an argument to match a parameter, returns false if no matching results left 316 316 bool instantiateArgument( 317 const CodeLocation & location, 317 318 const ast::Type * paramType, const ast::Init * init, const ExplodedArgs_new & args, 318 319 std::vector< ArgPack > & results, std::size_t & genStart, const ast::SymbolTable & symtab, … … 325 326 // xxx - dropping initializer changes behaviour from previous, but seems correct 326 327 // ^^^ need to handle the case where a tuple has a default argument 327 if ( ! instantiateArgument( 328 if ( ! instantiateArgument( location, 328 329 type, nullptr, args, results, genStart, symtab, nTuples ) ) return false; 329 330 nTuples = 0; … … 377 378 // push empty tuple expression 378 379 newResult.parent = i; 379 newResult.expr = new ast::TupleExpr { CodeLocation{}, {} };380 newResult.expr = new ast::TupleExpr( location, {} ); 380 381 argType = newResult.expr->result; 381 382 } else { … … 692 693 /// Builds a list of candidates for a function, storing them in out 693 694 void makeFunctionCandidates( 695 const CodeLocation & location, 694 696 const CandidateRef & func, const ast::FunctionType * funcType, 695 697 const ExplodedArgs_new & args, CandidateList & out … … 738 740 for (size_t i=0; i<nParams; ++i) { 739 741 auto obj = funcDecl->params[i].strict_as<ast::ObjectDecl>(); 740 if ( !instantiateArgument(742 if ( !instantiateArgument( location, 741 743 funcType->params[i], obj->init, args, results, genStart, symtab)) return; 742 744 } … … 748 750 // matches 749 751 // no default args for indirect calls 750 if ( ! instantiateArgument(752 if ( !instantiateArgument( location, 751 753 param, nullptr, args, results, genStart, symtab ) ) return; 752 754 } … … 978 980 newFunc->expr = 979 981 referenceToRvalueConversion( newFunc->expr, newFunc->cost ); 980 makeFunctionCandidates( newFunc, function, argExpansions, found ); 982 makeFunctionCandidates( untypedExpr->location, 983 newFunc, function, argExpansions, found ); 981 984 } 982 985 } else if ( … … 985 988 if ( const ast::EqvClass * clz = func->env.lookup( *inst ) ) { 986 989 if ( auto function = clz->bound.as< ast::FunctionType >() ) { 987 CandidateRef newFunc { new Candidate{ *func } };990 CandidateRef newFunc( new Candidate( *func ) ); 988 991 newFunc->expr = 989 992 referenceToRvalueConversion( newFunc->expr, newFunc->cost ); 990 makeFunctionCandidates( newFunc, function, argExpansions, found ); 993 makeFunctionCandidates( untypedExpr->location, 994 newFunc, function, argExpansions, found ); 991 995 } 992 996 } … … 1014 1018 newOp->expr = 1015 1019 referenceToRvalueConversion( newOp->expr, newOp->cost ); 1016 makeFunctionCandidates( newOp, function, argExpansions, found ); 1020 makeFunctionCandidates( untypedExpr->location, 1021 newOp, function, argExpansions, found ); 1017 1022 } 1018 1023 } … … 1179 1184 thisCost.incSafe( discardedValues ); 1180 1185 // select first on argument cost, then conversion cost 1181 if ( cand->cost < minExprCost || cand->cost == minExprCost && thisCost < minCastCost) {1186 if ( cand->cost < minExprCost || ( cand->cost == minExprCost && thisCost < minCastCost ) ) { 1182 1187 minExprCost = cand->cost; 1183 1188 minCastCost = thisCost; … … 1187 1192 } 1188 1193 // ambiguous case, still output candidates to print in error message 1189 if ( cand->cost == minExprCost && thisCost == minCastCost) {1194 if ( cand->cost == minExprCost && thisCost == minCastCost ) { 1190 1195 CandidateRef newCand = std::make_shared<Candidate>( 1191 1196 restructureCast( cand->expr, toType, castExpr->isGenerated ), … … 1700 1705 // count one safe conversion for each value that is thrown away 1701 1706 thisCost.incSafe( discardedValues ); 1702 if ( cand->cost < minExprCost || cand->cost == minExprCost && thisCost < minCastCost) {1707 if ( cand->cost < minExprCost || ( cand->cost == minExprCost && thisCost < minCastCost ) ) { 1703 1708 minExprCost = cand->cost; 1704 1709 minCastCost = thisCost; … … 1706 1711 } 1707 1712 // ambiguous case, still output candidates to print in error message 1708 if ( cand->cost == minExprCost && thisCost == minCastCost) {1713 if ( cand->cost == minExprCost && thisCost == minCastCost ) { 1709 1714 CandidateRef newCand = std::make_shared<Candidate>( 1710 1715 new ast::InitExpr{
Note: See TracChangeset
for help on using the changeset viewer.