Ignore:
Timestamp:
Feb 26, 2024, 3:53:42 AM (5 months ago)
Author:
JiadaL <j82liang@…>
Branches:
master
Children:
3f9a8d0
Parents:
0522ebe (diff), 022bce0 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Resolve conflict

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/CandidateFinder.cpp

    r0522ebe ra4da45e  
    10181018                                        }
    10191019
    1020                                         if (argType.as<ast::PointerType>()) funcFinder.otypeKeys.insert(Mangle::Encoding::pointer);                                             
     1020                                        if (argType.as<ast::PointerType>()) funcFinder.otypeKeys.insert(Mangle::Encoding::pointer);
    10211021                                        else funcFinder.otypeKeys.insert(Mangle::mangle(argType, Mangle::NoGenericParams | Mangle::Type));
    10221022                                }
     
    12831283                                                restructureCast( cand->expr, toType, castExpr->isGenerated ),
    12841284                                                copy( cand->env ), std::move( open ), std::move( need ), cand->cost + thisCost);
    1285                                         // currently assertions are always resolved immediately so this should have no effect. 
     1285                                        // currently assertions are always resolved immediately so this should have no effect.
    12861286                                        // if this somehow changes in the future (e.g. delayed by indeterminate return type)
    12871287                                        // we may need to revisit the logic.
     
    16181618        void Finder::postvisit( const ast::ConditionalExpr * conditionalExpr ) {
    16191619                // candidates for condition
     1620                ast::ptr<ast::Expr> arg1 = notZeroExpr( conditionalExpr->arg1 );
    16201621                CandidateFinder finder1( context, tenv );
    1621                 ast::ptr<ast::Expr> arg1 = notZeroExpr( conditionalExpr->arg1 );
    16221622                finder1.find( arg1, ResolveMode::withAdjustment() );
    16231623                if ( finder1.candidates.empty() ) return;
    16241624
    16251625                // candidates for true result
     1626                // FIX ME: resolves and runs arg1 twice when arg2 is missing.
     1627                ast::Expr const * arg2 = conditionalExpr->arg2;
     1628                arg2 = arg2 ? arg2 : conditionalExpr->arg1.get();
    16261629                CandidateFinder finder2( context, tenv );
    16271630                finder2.allowVoid = true;
    1628                 finder2.find( conditionalExpr->arg2, ResolveMode::withAdjustment() );
     1631                finder2.find( arg2, ResolveMode::withAdjustment() );
    16291632                if ( finder2.candidates.empty() ) return;
    16301633
     
    18971900                                        CandidateRef newCand =
    18981901                                                std::make_shared<Candidate>(
    1899                                                         newExpr, copy( tenv ), ast::OpenVarSet{}, 
     1902                                                        newExpr, copy( tenv ), ast::OpenVarSet{},
    19001903                                                        ast::AssertionSet{}, Cost::zero, cost
    19011904                                                );
    1902                                        
     1905
    19031906                                        if (newCand->expr->env) {
    19041907                                                newCand->env.add(*newCand->expr->env);
Note: See TracChangeset for help on using the changeset viewer.