Changeset 2870cb6 for src


Ignore:
Timestamp:
Aug 13, 2024, 6:17:27 PM (3 months ago)
Author:
Fangren Yu <f37yu@…>
Branches:
master
Children:
1a2ba84, d1f5054
Parents:
661e7b0
Message:

update cast expression cost rule

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/CandidateFinder.cpp

    r661e7b0 r2870cb6  
    12811281                                // count one safe conversion for each value that is thrown away
    12821282                                thisCost.incSafe( discardedValues );
     1283
     1284                                // See Aaron Moss, page 47; this reasoning does not hold since implicit conversions
     1285                                // can create the same resolution issue. The C intrinsic interpretations are pruned
     1286                                // immediately for the lowest cost option regardless of result type. Related code in
     1287                                // postvisit (UntypedExpr).
     1288                                // Cast expression costs are updated now to use the general rules.
     1289                                /*
    12831290                                // select first on argument cost, then conversion cost
    12841291                                if ( cand->cost < minExprCost || ( cand->cost == minExprCost && thisCost < minCastCost ) ) {
     
    12891296                                // ambigious case, still output candidates to print in error message
    12901297                                if ( cand->cost == minExprCost && thisCost == minCastCost ) {
     1298                                */
     1299                                cand->cost += thisCost;
     1300                                if (cand->cost < minExprCost) {
     1301                                        minExprCost = cand->cost;
     1302                                        matches.clear();
     1303                                }
     1304                                if (cand->cost == minExprCost) {
    12911305                                        CandidateRef newCand = std::make_shared<Candidate>(
    12921306                                                restructureCast( cand->expr, toType, castExpr->isGenerated ),
    1293                                                 copy( cand->env ), std::move( open ), std::move( need ), cand->cost + thisCost);
     1307                                                copy( cand->env ), std::move( open ), std::move( need ), cand->cost);
    12941308                                        // currently assertions are always resolved immediately so this should have no effect.
    12951309                                        // if this somehow changes in the future (e.g. delayed by indeterminate return type)
Note: See TracChangeset for help on using the changeset viewer.