Skip to content

Commit

Permalink
- Added a generic error message for failing to instantiate an equation
Browse files Browse the repository at this point in the history
  - There are many ways that the equations can fail, and only error messages for some; it's important to at least print something
- Closing bug #1239 (which had 2 errors in it; neither of which were caught)


git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@5922 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed Aug 13, 2010
1 parent 3298842 commit 66dc286
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
4 changes: 3 additions & 1 deletion Compiler/Error.mo
Expand Up @@ -217,6 +217,7 @@ public constant ErrorID HIGHER_VARIABILITY_BINDING=129;
public constant ErrorID STRUCT_SINGULAR_EQUATION=130;
public constant ErrorID IF_EQUATION_WARNING=131;
public constant ErrorID IF_EQUATION_UNBALANCED_2=132;
public constant ErrorID EQUATION_GENERIC_FAILURE=133;

public constant ErrorID UNBOUND_PARAMETER_WARNING=500;
public constant ErrorID BUILTIN_FUNCTION_SUM_HAS_SCALAR_PARAMETER=501;
Expand Down Expand Up @@ -562,7 +563,8 @@ protected constant list<tuple<Integer, MessageType, Severity, String>> errorTabl
(MATCH_SHADOWING, TRANSLATION(),ERROR(), " Local variable '%s' shadows input or result variables in a {match,matchcontinue} expression."),
(META_POLYMORPHIC, TRANSLATION(),ERROR(), " %s uses invalid subtypeof syntax. Only subtypeof Any is supported."),
(META_FUNCTION_TYPE_NO_PARTIAL_PREFIX, TRANSLATION(),ERROR(), "%s is used as a function reference, but doesn't specify the partial prefix."),
(IF_EQUATION_WARNING,SYMBOLIC(),WARNING(), "If-equations are only partially supported. Ignoring%s")
(IF_EQUATION_WARNING,SYMBOLIC(),WARNING(), "If-equations are only partially supported. Ignoring%s"),
(EQUATION_GENERIC_FAILURE,TRANSLATION(),ERROR(),"Failed to instantiate equation %s")

};

Expand Down
7 changes: 4 additions & 3 deletions Compiler/Inst.mo
Expand Up @@ -11469,9 +11469,10 @@ algorithm

case (_,env,ih,_,_,_,_,eqn,_,impl,graph)
equation
true = RTOpts.debugFlag("failtrace");
Debug.fprint("failtrace", "- instEquationCommon failed for eqn: ");
s = SCode.equationStr(eqn);
Error.addSourceMessage(Error.EQUATION_GENERIC_FAILURE, {s}, SCode.equationFileInfo(eqn));
true = RTOpts.debugFlag("failtrace");
Debug.fprint("failtrace", "- instEquationCommon failed for eqn: ");
Debug.fprint("failtrace", s +& " in scope:" +& Env.getScopeName(env) +& "\n");
then
fail();
Expand Down Expand Up @@ -11744,7 +11745,7 @@ algorithm
t2_str = Types.unparseType(t2);
s1 = Util.stringAppendList({e1_str,"=",e2_str});
s2 = Util.stringAppendList({t1_str,"=",t2_str});
Error.addMessage(Error.EQUATION_TYPE_MISMATCH_ERROR, {s1,s2});
Error.addSourceMessage(Error.EQUATION_TYPE_MISMATCH_ERROR, {s1,s2}, DAEUtil.getElementSourceFileInfo(source));
Debug.fprintln("failtrace", "- Inst.instEqEquation failed with type mismatch in equation: " +& s1 +& " tys: " +& s2);
then
fail();
Expand Down
17 changes: 17 additions & 0 deletions Compiler/SCode.mo
Expand Up @@ -2623,5 +2623,22 @@ algorithm
end matchcontinue;
end findIteratorInElseIfBranch;

public function equationFileInfo
input EEquation eq;
output Absyn.Info info;
algorithm
info := matchcontinue eq
case EQ_IF(info=info) then info;
case EQ_EQUALS(info=info) then info;
case EQ_CONNECT(info=info) then info;
case EQ_FOR(info=info) then info;
case EQ_WHEN(info=info) then info;
case EQ_ASSERT(info=info) then info;
case EQ_TERMINATE(info=info) then info;
case EQ_REINIT(info=info) then info;
case EQ_NORETCALL(info=info) then info;
end matchcontinue;
end equationFileInfo;

end SCode;

0 comments on commit 66dc286

Please sign in to comment.