Skip to content

Commit

Permalink
Fix for elabBuiltinSize of zero-size arrays
Browse files Browse the repository at this point in the history
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]:
  - OpenModelica/OMCompiler#2074
  • Loading branch information
sjoelund authored and OpenModelica-Hudson committed Dec 13, 2017
1 parent cdf224b commit fb52840
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions Compiler/FrontEnd/Static.mo
Expand Up @@ -3241,7 +3241,7 @@ algorithm
FCore.Cache cache;
Prefix.Prefix pre;
DAE.Type ety;
DAE.Dimensions dims;
DAE.Dimensions dims, dims1, dims2;

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

Expand Down

0 comments on commit fb52840

Please sign in to comment.