Skip to content

Commit

Permalink
Fatal error when input variable is differentiated. (#9804)
Browse files Browse the repository at this point in the history
* Fatal error when input variable is differentiated.
  - Error was not fatal before and the compiler didn't stop until the C compiler failed on the generated garbage code.
  • Loading branch information
AnHeuermann committed Dec 5, 2022
1 parent 6449de3 commit 6368c1c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions OMCompiler/Compiler/BackEnd/BackendDAEUtil.mo
Expand Up @@ -9367,6 +9367,7 @@ algorithm
end setFunctionTree;

public function setEqSystEqs
"Set ordered equations of input equation system to given equations."
input BackendDAE.EqSystem inSyst;
input BackendDAE.EquationArray inEqs;
output BackendDAE.EqSystem syst = inSyst;
Expand Down
7 changes: 7 additions & 0 deletions OMCompiler/Compiler/BackEnd/SymbolicJacobian.mo
Expand Up @@ -464,6 +464,8 @@ protected function inputDerivativesUsedWork "author: Frenkel TUD 2012-10"
output BackendDAE.EqSystem osyst;
output BackendDAE.Shared outShared = inShared "unused";
output Boolean outChanged;
protected
Boolean hasFailed = false;
algorithm
(osyst, outChanged) := matchcontinue(isyst)
local
Expand All @@ -474,10 +476,15 @@ algorithm
((_, explst as _::_)) = BackendDAEUtil.traverseBackendDAEExpsEqns(orderedEqs, traverserinputDerivativesUsed, (BackendVariable.daeGlobalKnownVars(inShared), {}));
s = stringDelimitList(List.map(explst, ExpressionDump.printExpStr), "\n");
Error.addMessage(Error.DERIVATIVE_INPUT, {s});
hasFailed = true;
then (BackendDAEUtil.setEqSystEqs(isyst, orderedEqs), true);

else (isyst, inChanged);
end matchcontinue;

// Fail after error is displayed.
// We do it this way, because I was to lazy to rewrite all of this function.
if hasFailed then fail(); end if;
end inputDerivativesUsedWork;

protected function traverserinputDerivativesUsed "author: Frenkel TUD 2012-10"
Expand Down

0 comments on commit 6368c1c

Please sign in to comment.