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

Commit 84be5a9

Browse files
perostOpenModelica-Hudson
authored andcommitted
[NF] Fix variability issues.
- When typing subscripts, fetch the actual variability of already typed subscripts instead of assuming they're constant. - Don't go into crefs when evaluating 'end', it's more efficient to let the recursive typing handle it. Belonging to [master]: - #2485 - OpenModelica/OpenModelica-testsuite#969
1 parent 2fffc20 commit 84be5a9

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

Compiler/NFFrontEnd/NFTyping.mo

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1371,7 +1371,7 @@ protected
13711371
Type ty, ety;
13721372
MatchKind mk;
13731373
algorithm
1374-
ty := match subscript
1374+
(ty, variability) := match subscript
13751375
// An untyped subscript, type the expression and create a typed subscript.
13761376
case Subscript.UNTYPED()
13771377
algorithm
@@ -1385,15 +1385,15 @@ algorithm
13851385
outSubscript := Subscript.INDEX(e);
13861386
end if;
13871387
then
1388-
ty;
1388+
(ty, variability);
13891389

1390-
// Other subscripts have already been typed, but still need to be type checked.
1391-
case Subscript.INDEX() then Expression.typeOf(subscript.index);
1392-
case Subscript.SLICE() then Type.unliftArray(Expression.typeOf(subscript.slice));
1393-
case Subscript.WHOLE() then Type.UNKNOWN();
1390+
//// Other subscripts have already been typed, but still need to be type checked.
1391+
case Subscript.INDEX(index = e) then (Expression.typeOf(e), Expression.variability(e));
1392+
case Subscript.SLICE(slice = e) then (Type.unliftArray(Expression.typeOf(e)), Expression.variability(e));
1393+
case Subscript.WHOLE() then (Type.UNKNOWN(), Dimension.variability(dimension));
13941394
else
13951395
algorithm
1396-
Error.assertion(false, getInstanceName() + " got untyped subscript", sourceInfo());
1396+
Error.assertion(false, getInstanceName() + " got unknown subscript", sourceInfo());
13971397
then
13981398
fail();
13991399
end match;
@@ -1802,11 +1802,9 @@ function evaluateEnd
18021802

18031803
case Expression.END() then Dimension.endExp(dim, cref, index);
18041804

1805-
case Expression.CREF()
1806-
algorithm
1807-
(cr, ty) := typeCref(exp.cref, origin, info);
1808-
then
1809-
Expression.CREF(ty, cr);
1805+
// Stop when encountering a cref, any 'end' in a cref expression refers to
1806+
// the cref's dimensions and will be evaluated when the cref is typed.
1807+
case Expression.CREF() then exp;
18101808

18111809
else Expression.mapShallow(exp,
18121810
function evaluateEnd(dim = dim, cref = cref, index = index, info = info, origin = origin));

0 commit comments

Comments
 (0)