Changeset ea83e00a
- Timestamp:
- Dec 13, 2016, 5:01:51 PM (8 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 722617d
- Parents:
- 7933351
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/AlternativeFinder.cc
r7933351 rea83e00a 608 608 makeUnifiableVars( funcType, openVars, resultNeed ); 609 609 AltList instantiatedActuals; // filled by instantiate function 610 if ( targetType && ! targetType->isVoid() ) { 611 // attempt to narrow based on expected target type 612 Type * returnType = funcType->get_returnVals().front()->get_type(); 613 if ( ! unify( returnType, targetType, resultEnv, resultNeed, resultHave, openVars, indexer ) ) { 614 // unification failed, don't pursue this alternative 615 return; 616 } 617 } 618 610 619 if ( instantiateFunction( funcType->get_parameters(), actualAlt, funcType->get_isVarArgs(), openVars, resultEnv, resultNeed, resultHave, instantiatedActuals ) ) { 611 620 ApplicationExpr *appExpr = new ApplicationExpr( func.expr->clone() ); … … 740 749 741 750 findMinCost( candidates.begin(), candidates.end(), std::back_inserter( alternatives ) ); 751 752 if ( alternatives.empty() && targetType && ! targetType->isVoid() ) { 753 // xxx - this is a temporary hack. If resolution is unsuccessful with a target type, try again without a 754 // target type, since it will sometimes succeed when it wouldn't easily with target type binding. For example, 755 // forall( otype T ) lvalue T ?[?]( T *, ptrdiff_t ); 756 // const char * x = "hello world"; 757 // unsigned char ch = x[0]; 758 // Fails with simple return type binding. First, T is bound to unsigned char, then (x: const char *) is unified 759 // with unsigned char *, which fails because pointer base types must be unified exactly. The new resolver should 760 // fix this issue in a more robust way. 761 targetType = nullptr; 762 visit( untypedExpr ); 763 } 742 764 } 743 765
Note: See TracChangeset
for help on using the changeset viewer.