Skip to content

Commit

Permalink
Improve error message for mismatched connectors (#10676)
Browse files Browse the repository at this point in the history
  • Loading branch information
perost committed May 10, 2023
1 parent c9210b3 commit 949bcee
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion OMCompiler/Compiler/NFFrontEnd/NFExpandableConnectors.mo
Expand Up @@ -476,7 +476,7 @@ algorithm
(_, _, _, mk) := TypeCheck.matchExpressions(e1, ty1, e2, ty2, allowUnknown = true);

if TypeCheck.isIncompatibleMatch(mk) then
Error.addSourceMessageAndFail(Error.INVALID_CONNECTOR_VARIABLE,
Error.addSourceMessageAndFail(Error.CONNECT_TYPE_MISMATCH,
{Expression.toString(e1), Expression.toString(e2)}, Connector.getInfo(c1));
end if;

Expand Down
2 changes: 1 addition & 1 deletion OMCompiler/Compiler/NFFrontEnd/NFTyping.mo
Expand Up @@ -3021,7 +3021,7 @@ algorithm

if TypeCheck.isIncompatibleMatch(mk) then
// TODO: Better error message.
Error.addSourceMessage(Error.INVALID_CONNECTOR_VARIABLE,
Error.addSourceMessage(Error.CONNECT_TYPE_MISMATCH,
{Expression.toString(lhsConn), Expression.toString(rhsConn)}, info);
fail();
end if;
Expand Down
2 changes: 2 additions & 0 deletions OMCompiler/Compiler/Util/Error.mo
Expand Up @@ -885,6 +885,8 @@ public constant ErrorTypes.Message PARTIAL_DERIVATIVE_INPUT_NOT_FOUND = ErrorTyp
Gettext.gettext("‘%s‘ in partial derivative of ‘%s‘ does not name an input parameter of the function."));
public constant ErrorTypes.Message PARTIAL_DERIVATIVE_INPUT_INVALID_TYPE = ErrorTypes.MESSAGE(405, ErrorTypes.TRANSLATION(), ErrorTypes.ERROR(),
Gettext.gettext("‘%s‘ in partial derivative of ‘%s‘ is not a scalar Real input parameter of the function."));
public constant ErrorTypes.Message CONNECT_TYPE_MISMATCH = ErrorTypes.MESSAGE(406, ErrorTypes.TRANSLATION(), ErrorTypes.ERROR(),
Gettext.gettext("The connectors in connect(%s, %s) are not type compatible."));

public constant ErrorTypes.Message INITIALIZATION_NOT_FULLY_SPECIFIED = ErrorTypes.MESSAGE(496, ErrorTypes.TRANSLATION(), ErrorTypes.WARNING(),
Gettext.gettext("The initial conditions are not fully specified. %s."));
Expand Down
Expand Up @@ -17,8 +17,7 @@ end ConnectInvalidType1;

// Result:
// Error processing file: ConnectInvalidType1.mo
// [flattening/modelica/scodeinst/ConnectInvalidType1.mo:15:3-15:18:writable] Error: The type of variables c1 and c2
// are inconsistent in connect equations.
// [flattening/modelica/scodeinst/ConnectInvalidType1.mo:15:3-15:18:writable] Error: The connectors in connect(c1, c2) are not type compatible.
//
// # Error encountered! Exiting...
// # Please check the error message and the flags.
Expand Down
Expand Up @@ -23,8 +23,7 @@ end ConnectInvalidType2;

// Result:
// Error processing file: ConnectInvalidType2.mo
// [flattening/modelica/scodeinst/ConnectInvalidType2.mo:21:3-21:18:writable] Error: The type of variables c1 and c2
// are inconsistent in connect equations.
// [flattening/modelica/scodeinst/ConnectInvalidType2.mo:21:3-21:18:writable] Error: The connectors in connect(c1, c2) are not type compatible.
//
// # Error encountered! Exiting...
// # Please check the error message and the flags.
Expand Down

0 comments on commit 949bcee

Please sign in to comment.