Skip to content

Commit

Permalink
[NF] Compare names when type checking connections.
Browse files Browse the repository at this point in the history
  • Loading branch information
perost committed Jun 22, 2019
1 parent 4698d26 commit da81d44
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
6 changes: 6 additions & 0 deletions OMCompiler/Compiler/NFFrontEnd/NFTypeCheck.mo
Expand Up @@ -2363,6 +2363,12 @@ algorithm
else
for c1 in comps1 loop
c2 :: rest_c2 := rest_c2;

if InstNode.name(c1) <> InstNode.name(c2) then
matchKind := MatchKind.NOT_COMPATIBLE;
return;
end if;

(_, _, matchKind) := matchTypes(InstNode.getType(c1), InstNode.getType(c2), dummy, allowUnknown);

if matchKind == MatchKind.NOT_COMPATIBLE then
Expand Down
33 changes: 33 additions & 0 deletions testsuite/flattening/modelica/scodeinst/ConnectInvalidType2.mo
@@ -0,0 +1,33 @@
// name: ConnectInvalidType2
// keywords:
// status: incorrect
// cflags: -d=newInst
//

connector C1
Real e;
flow Real f;
end C1;

connector C2
Real e2;
flow Real f2;
end C2;

model ConnectInvalidType2
C1 c1;
C2 c2;
equation
connect(c1, c2);
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.
//
// # Error encountered! Exiting...
// # Please check the error message and the flags.
//
// Execution failed!
// endResult
1 change: 1 addition & 0 deletions testsuite/flattening/modelica/scodeinst/Makefile
Expand Up @@ -229,6 +229,7 @@ ConnectExternalObject1.mo \
ConnectInitial.mo \
ConnectInvalidForm1.mo \
ConnectInvalidType1.mo \
ConnectInvalidType2.mo \
ConnectNonConnector1.mo \
ConnectNonConnector2.mo \
ConnectNonConnector3.mo \
Expand Down

0 comments on commit da81d44

Please sign in to comment.