Skip to content

Commit

Permalink
Fix regressions due to #12315 (#12342)
Browse files Browse the repository at this point in the history
- Don't add start values from types as bindings to parameters without
  bindings, they aren't handled correctly.
  • Loading branch information
perost committed Apr 29, 2024
1 parent 60c2b6e commit a024851
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 1 deletion.
13 changes: 13 additions & 0 deletions OMCompiler/Compiler/NFFrontEnd/NFBinding.mo
Expand Up @@ -834,5 +834,18 @@ public
end match;
end isEvaluated;

function hasTypeOrigin
input Binding binding;
output Boolean res;
algorithm
res := match binding
case RAW_BINDING()
guard not listEmpty(binding.subs)
then Subscript.isSplitClassProxy(listHead(binding.subs));

else false;
end match;
end hasTypeOrigin;

annotation(__OpenModelica_Interface="frontend");
end NFBinding;
2 changes: 1 addition & 1 deletion OMCompiler/Compiler/NFFrontEnd/NFInst.mo
Expand Up @@ -2268,7 +2268,7 @@ algorithm

binding := Component.getTypeAttributeBinding(comp, "start");

if Binding.isBound(binding) then
if Binding.isBound(binding) and not Binding.hasTypeOrigin(binding) then
if not InstContext.inRelaxed(context) then
Error.addSourceMessage(Error.UNBOUND_PARAMETER_WITH_START_VALUE_WARNING,
{AbsynUtil.pathString(InstNode.scopePath((node))), Binding.toString(binding)}, InstNode.info(node));
Expand Down
10 changes: 10 additions & 0 deletions OMCompiler/Compiler/NFFrontEnd/NFSubscript.mo
Expand Up @@ -1264,6 +1264,16 @@ public
end match;
end isSplitIndex;

function isSplitClassProxy
input Subscript sub;
output Boolean res;
algorithm
res := match sub
case SPLIT_PROXY() then InstNode.isClass(sub.origin);
else false;
end match;
end isSplitClassProxy;

function expandSplitIndices
input list<Subscript> subs;
input list<InstNode> indicesToKeep = {};
Expand Down
1 change: 1 addition & 0 deletions testsuite/flattening/modelica/scodeinst/Makefile
Expand Up @@ -1153,6 +1153,7 @@ TypenameInvalid2.mo \
TypenameInvalid3.mo \
UnboundParameter1.mo \
UnboundParameter2.mo \
UnboundParameter3.mo \
usertype1.mo \
usertype2.mo \
usertype3.mo \
Expand Down
20 changes: 20 additions & 0 deletions testsuite/flattening/modelica/scodeinst/UnboundParameter3.mo
@@ -0,0 +1,20 @@
// name: UnboundParameter3
// keywords:
// status: correct
// cflags: -d=newInst
//

model UnboundParameter3
type T = Real(start = 1.0);
parameter T x[3];
end UnboundParameter3;

// Result:
// class UnboundParameter3
// parameter Real x[1](start = 1.0);
// parameter Real x[2](start = 1.0);
// parameter Real x[3](start = 1.0);
// end UnboundParameter3;
// [flattening/modelica/scodeinst/UnboundParameter3.mo:9:3-9:19:writable] Warning: Parameter x has no value, and is fixed during initialization (fixed=true), using available start value (start=fill(1.0, 3)) as default value.
//
// endResult

0 comments on commit a024851

Please sign in to comment.