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

Commit 3d7f6a4

Browse files
perostOpenModelica-Hudson
authored andcommitted
[NF] Fix evaluation of dimensions in functions.
- Only evaluate structural parameter dimensions in functions, not non-structural parameters. Belonging to [master]: - #2426
1 parent 0e2c8f5 commit 3d7f6a4

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

Compiler/NFFrontEnd/NFTyping.mo

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -510,15 +510,19 @@ algorithm
510510
info, replaceConstants = false);
511511
TypeCheck.checkDimensionType(exp, ty, info);
512512

513-
if var <= Variability.PARAMETER then
514-
// Evaluate the dimension if it's a parameter expression.
515-
exp := Ceval.evalExp(exp, Ceval.EvalTarget.DIMENSION(component, index, exp, info));
516-
else
517-
// Dimensions must be parameter expressions, unless we're in a function.
518-
if intBitAnd(origin, ExpOrigin.FUNCTION) == 0 then
513+
if intBitAnd(origin, ExpOrigin.FUNCTION) == 0 then
514+
// Dimensions must be parameter expressions in a non-function class.
515+
if var <= Variability.PARAMETER then
516+
exp := Ceval.evalExp(exp, Ceval.EvalTarget.DIMENSION(component, index, exp, info));
517+
else
519518
Error.addSourceMessage(Error.DIMENSION_NOT_KNOWN,
520519
{Expression.toString(exp)}, info);
521-
fail();
520+
fail();
521+
end if;
522+
else
523+
// For functions, only evaluate constant and structural parameter expressions.
524+
if var <= Variability.STRUCTURAL_PARAMETER then
525+
exp := Ceval.evalExp(exp, Ceval.EvalTarget.DIMENSION(component, index, exp, info));
522526
end if;
523527
end if;
524528

0 commit comments

Comments
 (0)