diff --git a/Compiler/NFFrontEnd/NFCall.mo b/Compiler/NFFrontEnd/NFCall.mo index 119f95ca61b..79f389d9c4a 100644 --- a/Compiler/NFFrontEnd/NFCall.mo +++ b/Compiler/NFFrontEnd/NFCall.mo @@ -970,6 +970,10 @@ protected if listLength(matchedFunctions) > 1 then exactMatches := MatchedFunction.getExactMatches(matchedFunctions); + if listEmpty(exactMatches) then + exactMatches := MatchedFunction.getExactVectorizedMatches(matchedFunctions); + end if; + if listLength(exactMatches) > 1 then Error.addSourceMessage(Error.AMBIGUOUS_MATCHING_FUNCTIONS_NFINST, {typedString(call), Function.candidateFuncListString(list(mfn.func for mfn in matchedFunctions))}, info); diff --git a/Compiler/NFFrontEnd/NFFunction.mo b/Compiler/NFFrontEnd/NFFunction.mo index 7c800cdf857..d66bd22509a 100644 --- a/Compiler/NFFrontEnd/NFFunction.mo +++ b/Compiler/NFFrontEnd/NFFunction.mo @@ -134,6 +134,7 @@ uniontype FunctionMatchKind // Instead they are added to each call as is. // This list represents which args should be vectorized. list is_vectorized; + FunctionMatchKind baseMatch; end VECTORIZED; record NOT_COMPATIBLE end NOT_COMPATIBLE; @@ -168,6 +169,16 @@ uniontype FunctionMatchKind end match; end isVectorized; + function isExactVectorized + input FunctionMatchKind mk; + output Boolean b; + algorithm + b := match mk + case VECTORIZED(baseMatch = EXACT()) then true; + else false; + end match; + end isExactVectorized; + end FunctionMatchKind; constant FunctionMatchKind EXACT_MATCH = FunctionMatchKind.EXACT(); @@ -192,6 +203,12 @@ uniontype MatchedFunction output list outFuncs = list(mf for mf guard(FunctionMatchKind.isExact(mf.mk)) in matchedFunctions); end getExactMatches; + function getExactVectorizedMatches + input list matchedFunctions; + output list outFuncs = + list(mf for mf guard(FunctionMatchKind.isExactVectorized(mf.mk)) in matchedFunctions); + end getExactVectorizedMatches; + function isVectorized input MatchedFunction mf; output Boolean b = FunctionMatchKind.isVectorized(mf.mk); @@ -736,6 +753,7 @@ uniontype Function list argdims, compdims, vectdims, tmpdims, outvectdims; Boolean has_cast; list vectorized; + FunctionMatchKind base_mk = EXACT_MATCH; algorithm checked_args := {}; @@ -806,13 +824,19 @@ uniontype Function return; end if; + if TypeCheck.isCastMatch(matchKind) then + base_mk := CAST_MATCH; + elseif TypeCheck.isGenericMatch(matchKind) then + base_mk := GENERIC_MATCH; + end if; + checked_args := (margexp,mty,var) :: checked_args; idx := idx + 1; end for; correct := true; args := listReverse(checked_args); - funcMatchKind := VECTORIZED(vectdims, listReverse(vectorized)); + funcMatchKind := VECTORIZED(vectdims, listReverse(vectorized), base_mk); end matchArgsVectorize; function matchArgs