Skip to content

Commit bc8cd00

Browse files
committed
Don't update bindings of redeclared parameters
- Don't create a binding from the start value of an unbound parameter if the parameter is being redeclared. Fixes 14099
1 parent 8f898f4 commit bc8cd00

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

OMCompiler/Compiler/NFFrontEnd/NFInst.mo

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2360,6 +2360,11 @@ protected
23602360
Absyn.Exp aexp;
23612361
list<Absyn.Exp> args;
23622362
algorithm
2363+
if InstContext.inRedeclared(context) then
2364+
// Don't update the binding if the parameter is being redeclared.
2365+
return;
2366+
end if;
2367+
23632368
comp := InstNode.component(node);
23642369

23652370
if not Component.isFixed(comp) or InstNode.hasBinding(node) then

testsuite/flattening/modelica/scodeinst/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1184,6 +1184,7 @@ UnboundParameter3.mo \
11841184
UnboundParameter4.mo \
11851185
UnboundParameter5.mo \
11861186
UnboundParameter6.mo \
1187+
UnboundParameter7.mo \
11871188
usertype1.mo \
11881189
usertype2.mo \
11891190
usertype3.mo \
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// name: UnboundParameter7
2+
// keywords:
3+
// status: correct
4+
//
5+
6+
model A
7+
replaceable parameter Real x(start = 1.0);
8+
end A;
9+
10+
model UnboundParameter7
11+
extends A(redeclare Real x = 1.0);
12+
end UnboundParameter7;
13+
14+
// Result:
15+
// class UnboundParameter7
16+
// parameter Real x(start = 1.0) = 1.0;
17+
// end UnboundParameter7;
18+
// endResult

0 commit comments

Comments
 (0)