- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/CandidateFinder.cpp
rbfa7bf0 rd68a3f7 522 522 CandidateFinder subFinder( context, env ); 523 523 expr = subFinder.makeEnumOffsetCast(argAsEnum, paramAsEnum, expr, c); 524 results.emplace_back( 525 i, expr, std::move( env ), std::move( need ), std::move( have ), std::move( open ), 526 nextArg + 1, nTuples, expl.cost + c, expl.exprs.size() == 1 ? 0 : 1, j ); 524 if ( expr ) 525 results.emplace_back( 526 i, expr, std::move( env ), std::move( need ), std::move( have ), std::move( open ), 527 nextArg + 1, nTuples, expl.cost + c, expl.exprs.size() == 1 ? 0 : 1, j ); 527 528 continue; 528 529 } else { … … 1265 1266 CandidateFinder subFinder(context, tenv); 1266 1267 ast::ptr<ast::Expr> offsetExpr = subFinder.makeEnumOffsetCast(argAsEnum, toAsEnum, cand->expr, thisCost); 1267 cand->expr = offsetExpr; 1268 if ( offsetExpr ) 1269 cand->expr = offsetExpr; 1268 1270 } 1269 1271 … … 2151 2153 2152 2154 const ast::Expr * CandidateFinder::makeEnumOffsetCast( const ast::EnumInstType * src, 2153 const ast::EnumInstType * dst, 2154 const ast::Expr * expr, 2155 Cost minCost ) { 2156 2155 const ast::EnumInstType * dst, const ast::Expr * expr, Cost minCost ) { 2157 2156 auto srcDecl = src->base; 2158 2157 auto dstDecl = dst->base; … … 2179 2178 CandidateRef & choice = winners.front(); 2180 2179 choice->expr = new ast::CastExpr(expr->location, choice->expr, dstChild, ast::GeneratedFlag::ExplicitCast); 2181 castToDst = new ast::CastExpr(2182 makeEnumOffsetCast( src, dstChild, choice->expr, minCost ),2183 dst);2180 auto destExpr = makeEnumOffsetCast( src, dstChild, choice->expr, minCost ); 2181 if ( !destExpr ) continue; 2182 castToDst = new ast::CastExpr( destExpr, dst ); 2184 2183 } else { 2185 2184 castToDst = new ast::CastExpr( expr, dst ); … … 2188 2187 } 2189 2188 } 2190 SemanticError(expr, src->base->name + " is not a subtype of " + dst->base->name);2191 2189 return nullptr; 2192 2190 }
Note: See TracChangeset
for help on using the changeset viewer.