Changeset 7aa209e7 for src/ResolvExpr/CandidateFinder.cpp
- Timestamp:
- Apr 17, 2024, 10:50:36 AM (6 months ago)
- Branches:
- master
- Children:
- 8fd53b6e
- Parents:
- 710d0c8c
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/CandidateFinder.cpp
r710d0c8c r7aa209e7 1400 1400 } 1401 1401 } 1402 1402 1403 1403 CandidateRef newCand = std::make_shared<Candidate>( 1404 1404 newExpr, copy( tenv ), ast::OpenVarSet{}, ast::AssertionSet{}, bentConversion? Cost::safe: Cost::zero, … … 1794 1794 auto commonAsEnumAttr = common.as<ast::EnumAttrType>(); 1795 1795 if ( commonAsEnumAttr && commonAsEnumAttr->attr == ast::EnumAttribute::Value ) { 1796 1797 1796 auto callExpr = new ast::UntypedExpr( 1798 1797 cand->expr->location, new ast::NameExpr( cand->expr->location, "valueE"), {cand->expr} ); … … 1823 1822 // if this somehow changes in the future (e.g. delayed by indeterminate return type) 1824 1823 // we may need to revisit the logic. 1825 inferParameters( newCand, matches ); 1824 inferParameters( newCand, matches ); 1826 1825 } 1827 } 1828 } 1826 } 1827 } 1829 1828 } 1830 1829 } … … 2151 2150 } 2152 2151 2153 // get the valueE(...) ApplicationExpr that returns the enum value 2154 const ast::Expr * getValueEnumCall( 2155 const ast::Expr * expr, 2156 const ResolvExpr::ResolveContext & context, const ast::TypeEnvironment & env ) { 2157 auto callExpr = new ast::UntypedExpr( 2158 expr->location, new ast::NameExpr( expr->location, "valueE"), {expr} ); 2159 CandidateFinder finder( context, env ); 2160 finder.find( callExpr ); 2161 CandidateList winners = findMinCost( finder.candidates ); 2162 if (winners.size() != 1) { 2163 SemanticError( callExpr, "Ambiguous expression in valueE" ); 2164 } 2165 CandidateRef & choice = winners.front(); 2166 return choice->expr; 2152 const ast::Expr * getValueEnumCall( const ast::Expr * expr, 2153 const ResolveContext & context, const ast::TypeEnvironment & env ) { 2154 auto callExpr = new ast::UntypedExpr( 2155 expr->location, new ast::NameExpr( expr->location, "valueE"), {expr} ); 2156 CandidateFinder finder( context, env ); 2157 finder.find( callExpr ); 2158 CandidateList winners = findMinCost( finder.candidates ); 2159 if (winners.size() != 1) { 2160 SemanticError( callExpr, "Ambiguous expression in valueE" ); 2161 } 2162 CandidateRef & choice = winners.front(); 2163 return choice->expr; 2167 2164 } 2168 2165
Note: See TracChangeset
for help on using the changeset viewer.