Skip to content
This repository was archived by the owner on May 18, 2019. It is now read-only.

Commit fb52840

Browse files
sjoelundOpenModelica-Hudson
authored andcommitted
Fix for elabBuiltinSize of zero-size arrays
Previously, we had work-arounds for T_UNKNOWN being passed to size. Since we fixed that, we now need to provide the correct number of dimensions. This is either the expression type or the type from elaboration; if we take the longer of the two we should get the correct number of dimensions. Belonging to [master]: - #2074
1 parent cdf224b commit fb52840

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

Compiler/FrontEnd/Static.mo

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3241,7 +3241,7 @@ algorithm
32413241
FCore.Cache cache;
32423242
Prefix.Prefix pre;
32433243
DAE.Type ety;
3244-
DAE.Dimensions dims;
3244+
DAE.Dimensions dims, dims1, dims2;
32453245

32463246
case (cache, env, {arraycr, dim}, impl, pre)
32473247
equation
@@ -3250,11 +3250,12 @@ algorithm
32503250
(cache, arraycrefe, prop, _) =
32513251
elabExpInExpression(cache, env, arraycr, impl, NONE(), false, pre, info);
32523252
ety = Expression.typeof(arraycrefe);
3253-
dims = Expression.arrayDimension(ety);
3253+
dims1 = Expression.arrayDimension(ety);
3254+
(,dims2) = Types.flattenArrayType(Types.getPropType(prop));
3255+
dims = if listLength(dims1) >= listLength(dims2) then dims1 else dims2 "In case there is a zero-size array somewhere...";
32543256
// sent in the props of the arraycrefe as if the array is constant then the size(x, 1) is constant!
32553257
// see Modelica.Media.Incompressible.Examples.Glycol47 and Modelica.Media.Incompressible.TableBased (hasDensity)
3256-
(SOME(exp), SOME(prop)) =
3257-
elabBuiltinSizeIndex(arraycrefe, prop, ety, dimp, dims, env, info);
3258+
(SOME(exp), SOME(prop)) = elabBuiltinSizeIndex(arraycrefe, prop, ety, dimp, dims, env, info);
32583259
then
32593260
(cache, exp, prop);
32603261

0 commit comments

Comments
 (0)