Skip to content

Commit

Permalink
Fix #8141 (#8142)
Browse files Browse the repository at this point in the history
- Fix the typing of `vector()` when the argument has 0-dimensions.
  • Loading branch information
perost committed Nov 15, 2021
1 parent 99a01c4 commit a83f551
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
6 changes: 6 additions & 0 deletions OMCompiler/Compiler/NFFrontEnd/NFBuiltinCall.mo
Expand Up @@ -1209,6 +1209,12 @@ protected
end if;
end for;

// The array might be empty even if one dimension is larger than 1,
// in that case the result will also be an empty array.
if Type.isEmptyArray(ty) then
vector_dim := Dimension.fromInteger(0);
end if;

ty := Type.ARRAY(Type.arrayElementType(ty), {vector_dim});
{fn} := Function.typeRefCache(fn_ref);
callExp := Expression.CALL(Call.makeTypedCall(fn, {arg}, variability, purity, ty));
Expand Down
Expand Up @@ -10,6 +10,7 @@ model FuncBuiltinVector
Real x[1] = vector(1);
Real y[3] = vector({{1}, {2}, {3}});
Real z[3] = vector({1, 2, 3});
Real w[0] = vector(zeros(0, 1));
end FuncBuiltinVector;

// Result:
Expand Down

0 comments on commit a83f551

Please sign in to comment.