@@ -1049,7 +1049,8 @@ protected
10491049 Expression arg;
10501050 Variability var ;
10511051 Function fn;
1052- Integer dim_size = -1 , i = 1 ;
1052+ Dimension vector_dim = Dimension . fromInteger(1 );
1053+ Boolean dim_found = false ;
10531054 algorithm
10541055 Call . UNTYPED_CALL (ref = fn_ref, arguments = args, named_args = named_args) := call;
10551056 assertNoNamedParams("vector" , named_args, info);
@@ -1064,27 +1065,18 @@ protected
10641065 // vector requires that at most one dimension is > 1, and that dimension
10651066 // determines the type of the vector call.
10661067 for dim in Type . arrayDims(ty) loop
1067- if Dimension . isKnown(dim) then
1068- if Dimension . size(dim) > 1 then
1069- if dim_size == -1 then
1070- dim_size := Dimension . size(dim);
1071- else
1072- Error . addSourceMessageAndFail(Error . NF_VECTOR_INVALID_DIMENSIONS ,
1073- {Type . toString(ty), Call . toString(call)}, info);
1074- end if ;
1068+ if not Dimension . isKnown(dim) or Dimension . size(dim) > 1 then
1069+ if dim_found then
1070+ Error . addSourceMessageAndFail(Error . NF_VECTOR_INVALID_DIMENSIONS ,
1071+ {Type . toString(ty), Call . toString(call)}, info);
1072+ else
1073+ vector_dim := dim;
1074+ dim_found := true ;
10751075 end if ;
10761076 end if ;
1077-
1078- i := i + 1 ;
10791077 end for ;
10801078
1081- // If the argument was scalar or an array where all dimensions where 1, set
1082- // the dimension size to 1.
1083- if dim_size == -1 then
1084- dim_size := 1 ;
1085- end if ;
1086-
1087- ty := Type . ARRAY (Type . arrayElementType(ty), {Dimension . fromInteger(dim_size)});
1079+ ty := Type . ARRAY (Type . arrayElementType(ty), {vector_dim});
10881080 {fn} := Function . typeRefCache(fn_ref);
10891081 callExp := Expression . CALL (Call . makeTypedCall(fn, {arg}, variability, ty));
10901082 end typeVectorCall;
0 commit comments