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

Commit bff7053

Browse files
ptaeuberOpenModelica-Hudson
authored andcommitted
Add warning for parameters with no binding
ticket:4189
1 parent 97e737e commit bff7053

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

Compiler/BackEnd/Initialization.mo

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -945,11 +945,14 @@ protected function selectParameter2 "author: lochel"
945945
algorithm
946946
outTpl := match (inVar, inTpl)
947947
local
948+
BackendDAE.Var var;
948949
BackendDAE.Variables vars, otherVars;
949950
BackendDAE.EquationArray eqns;
950951
DAE.Exp bindExp, crefExp, startValue;
951952
BackendDAE.Equation eqn;
952953
DAE.ComponentRef cref;
954+
String s, str;
955+
SourceInfo info;
953956

954957
// parameter without binding
955958
case (BackendDAE.VAR(varKind=BackendDAE.PARAM(), bindExp=NONE()), (vars, eqns, otherVars)) equation
@@ -960,6 +963,16 @@ algorithm
960963
startValue = BackendVariable.varStartValue(inVar);
961964
eqn = BackendDAE.EQUATION(crefExp, startValue, DAE.emptyElementSource, BackendDAE.EQ_ATTR_DEFAULT_INITIAL);
962965
eqns = BackendEquation.addEquation(eqn, eqns);
966+
967+
if BackendVariable.varFixed(inVar) then
968+
s = ComponentReference.printComponentRefStr(cref);
969+
str = ExpressionDump.printExpStr(startValue);
970+
var = BackendVariable.setVarKind(inVar, BackendDAE.VARIABLE());
971+
var = BackendVariable.setBindExp(var, SOME(startValue));
972+
var = BackendVariable.setVarFixed(var, true);
973+
info = ElementSource.getElementSourceFileInfo(BackendVariable.getVarSource(var));
974+
Error.addSourceMessage(Error.UNBOUND_PARAMETER_WITH_START_VALUE_WARNING, {s, str}, info);
975+
end if;
963976
then ((vars, eqns, otherVars));
964977

965978
// parameter with binding

0 commit comments

Comments
 (0)