@@ -963,30 +963,31 @@ uniontype Function
963963 (arg_exp, ty, mk) := TypeCheck . matchTypes(arg_ty, input_ty, arg_exp, allowUnknown = true );
964964 matched := TypeCheck . isValidArgumentMatch(mk);
965965
966- if matched then
967- // TODO: This should be a running reduction of the matches. Not just based on the
968- // last match.
969- if TypeCheck . isCastMatch(mk) then
970- funcMatchKind := CAST_MATCH ;
971- elseif TypeCheck . isGenericMatch(mk) then
972- funcMatchKind := GENERIC_MATCH ;
973- end if ;
974- elseif vectorize then
966+ if not matched and vectorize then
975967 // If the types don't match, try to vectorize the argument.
976- (arg_exp, ty, vect_arg, vect_dims, matched ) :=
968+ (arg_exp, ty, vect_arg, vect_dims, mk ) :=
977969 matchArgVectorized(arg_exp, arg_ty, input_ty, vect_arg, vect_dims, info);
978970 vectorized_args := arg_idx :: vectorized_args;
971+ matched := TypeCheck . isValidArgumentMatch(mk);
979972 end if ;
980973
981- // Print an error if the types don't match neither exactly nor vectorized.
982974 if not matched then
975+ // Print an error if the types match neither exactly nor vectorized.
983976 Error . addSourceMessage(Error . ARG_TYPE_MISMATCH ,
984977 {intString(arg_idx), Absyn . pathString(func . path), InstNode . name(input_node),
985978 Expression . toString(arg_exp), Type . toString(arg_ty), Type . toString(input_ty)}, info);
986979 funcMatchKind := NO_MATCH ;
987980 return ;
988981 end if ;
989982
983+ // TODO: This should be a running reduction of the matches. Not just based on the
984+ // last match.
985+ if TypeCheck . isCastMatch(mk) then
986+ funcMatchKind := CAST_MATCH ;
987+ elseif TypeCheck . isGenericMatch(mk) then
988+ funcMatchKind := GENERIC_MATCH ;
989+ end if ;
990+
990991 checked_args := (arg_exp, ty, arg_var) :: checked_args;
991992 arg_idx := arg_idx + 1 ;
992993 end for ;
@@ -1005,7 +1006,7 @@ uniontype Function
10051006 input output Expression vectArg;
10061007 input output list< Dimension > vectDims;
10071008 input SourceInfo info;
1008- output Boolean matched ;
1009+ output TypeCheck . MatchKind matchKind ;
10091010 protected
10101011 list< Dimension > arg_dims, input_dims, vect_dims, rest_dims;
10111012 Type rest_ty;
@@ -1018,7 +1019,7 @@ uniontype Function
10181019
10191020 // Only try to vectorize if the argument has more dimensions than the input parameter.
10201021 if vect_dims_count < 1 then
1021- matched := false ;
1022+ matchKind := MatchKind . NOT_COMPATIBLE ;
10221023 return ;
10231024 end if ;
10241025
@@ -1037,8 +1038,7 @@ uniontype Function
10371038 // Check that the argument and the input parameter are type compatible when
10381039 // the dimensions to vectorize over has been removed from the argument's type.
10391040 rest_ty := Type . liftArrayLeftList(Type . arrayElementType(argTy), rest_dims);
1040- (argExp, argTy, mk) := TypeCheck . matchTypes(rest_ty, inputTy, argExp, allowUnknown = false );
1041- matched := TypeCheck . isValidArgumentMatch(mk);
1041+ (argExp, argTy, matchKind) := TypeCheck . matchTypes(rest_ty, inputTy, argExp, allowUnknown = false );
10421042 end matchArgVectorized;
10431043
10441044 function fillUnknownVectorizedDims
0 commit comments