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

Commit c308368

Browse files
perostOpenModelica-Hudson
authored andcommitted
[NF] Fix Ceval.evalComponentBinding.
- Swap the order of trying to construct a binding and using the start value, using the start value should be the last thing we try if there's no explicit binding. Belonging to [master]: - #2785
1 parent 42eeda4 commit c308368

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

Compiler/NFFrontEnd/NFCeval.mo

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -312,17 +312,20 @@ algorithm
312312
binding := Component.getBinding(comp);
313313

314314
if Binding.isUnbound(binding) then
315-
// If the component has no binding, try to use the start value if possible.
316-
start_exp := evalComponentStartBinding(node, comp, cref, target, evalSubscripts);
317-
318-
if isSome(start_exp) then
319-
// The component had a valid start value, return it.
320-
SOME(exp) := start_exp;
321-
return;
322-
else
323-
// Otherwise we might need to construct a binding, for example when a
324-
// record has bindings on the fields but not on the record instance as a whole.
325-
binding := makeComponentBinding(comp, node, Expression.toCref(defaultExp), target);
315+
// In some cases we need to construct a binding for the node, for example when
316+
// a record has bindings on the fields but not on the record instance as a whole.
317+
binding := makeComponentBinding(comp, node, Expression.toCref(defaultExp), target);
318+
319+
if Binding.isUnbound(binding) then
320+
// If we couldn't construct a binding, try to use the start value instead.
321+
start_exp := evalComponentStartBinding(node, comp, cref, target, evalSubscripts);
322+
323+
if isSome(start_exp) then
324+
// The component had a valid start value. The value has already been
325+
// evaluated by evalComponentStartBinding, so skip the rest of the function.
326+
SOME(exp) := start_exp;
327+
return;
328+
end if;
326329
end if;
327330
end if;
328331

0 commit comments

Comments
 (0)