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

Commit d1a57b2

Browse files
perostOpenModelica-Hudson
authored andcommitted
[NF] Fix handling of duplicate outer elements.
Belonging to [master]: - #2073 - OpenModelica/OpenModelica-testsuite#803
1 parent dad39fb commit d1a57b2

3 files changed

Lines changed: 50 additions & 35 deletions

File tree

Compiler/NFFrontEnd/NFClass.mo

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -292,21 +292,25 @@ uniontype Class
292292
input Class cls2;
293293
output Boolean identical = false;
294294
algorithm
295-
identical := match (cls1, cls2)
296-
case (EXPANDED_CLASS(), EXPANDED_CLASS())
297-
then Prefixes.isEqual(cls1.prefixes, cls2.prefixes) and
298-
ClassTree.isIdentical(cls1.elements, cls2.elements);
299-
300-
case (INSTANCED_BUILTIN(), INSTANCED_BUILTIN())
301-
algorithm
302-
if not Type.isEqual(cls1.ty, cls2.ty) then
303-
return;
304-
end if;
305-
then
306-
true;
295+
if referenceEq(cls1, cls2) then
296+
identical := true;
297+
else
298+
identical := match (cls1, cls2)
299+
case (EXPANDED_CLASS(), EXPANDED_CLASS())
300+
then Prefixes.isEqual(cls1.prefixes, cls2.prefixes) and
301+
ClassTree.isIdentical(cls1.elements, cls2.elements);
302+
303+
case (INSTANCED_BUILTIN(), INSTANCED_BUILTIN())
304+
algorithm
305+
if not Type.isEqual(cls1.ty, cls2.ty) then
306+
return;
307+
end if;
308+
then
309+
true;
307310

308-
else true;
309-
end match;
311+
else true;
312+
end match;
313+
end if;
310314
end isIdentical;
311315

312316
function getDimensions

Compiler/NFFrontEnd/NFComponent.mo

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -504,22 +504,26 @@ uniontype Component
504504
input Component comp2;
505505
output Boolean identical = false;
506506
algorithm
507-
identical := match (comp1, comp2)
508-
case (UNTYPED_COMPONENT(), UNTYPED_COMPONENT())
509-
algorithm
510-
if not Class.isIdentical(InstNode.getClass(comp1.classInst),
511-
InstNode.getClass(comp2.classInst)) then
512-
return;
513-
end if;
514-
515-
if not Binding.isEqual(comp1.binding, comp2.binding) then
516-
return;
517-
end if;
518-
then
519-
true;
520-
521-
else true;
522-
end match;
507+
if referenceEq(comp1, comp2) then
508+
identical := true;
509+
else
510+
identical := match (comp1, comp2)
511+
case (UNTYPED_COMPONENT(), UNTYPED_COMPONENT())
512+
algorithm
513+
if not Class.isIdentical(InstNode.getClass(comp1.classInst),
514+
InstNode.getClass(comp2.classInst)) then
515+
return;
516+
end if;
517+
518+
if not Binding.isEqual(comp1.binding, comp2.binding) then
519+
return;
520+
end if;
521+
then
522+
true;
523+
524+
else true;
525+
end match;
526+
end if;
523527
end isIdentical;
524528

525529
function toString

Compiler/NFFrontEnd/NFInstNode.mo

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -981,17 +981,24 @@ uniontype InstNode
981981
function checkIdentical
982982
input InstNode node1;
983983
input InstNode node2;
984+
protected
985+
InstNode n1 = resolveOuter(node1);
986+
InstNode n2 = resolveOuter(node2);
984987
algorithm
985-
() := matchcontinue (node1, node2)
988+
if referenceEq(n1, n2) then
989+
return;
990+
end if;
991+
992+
() := matchcontinue (n1, n2)
986993
case (CLASS_NODE(), CLASS_NODE())
987-
guard Class.isIdentical(getClass(node1), getClass(node2)) then ();
994+
guard Class.isIdentical(getClass(n1), getClass(n2)) then ();
988995
case (COMPONENT_NODE(), COMPONENT_NODE())
989-
guard Component.isIdentical(component(node1), component(node2)) then ();
996+
guard Component.isIdentical(component(n1), component(n2)) then ();
990997
else
991998
algorithm
992999
Error.addMultiSourceMessage(Error.DUPLICATE_ELEMENTS_NOT_IDENTICAL,
993-
{toString(node1), toString(node2)},
994-
{InstNode.info(node1), InstNode.info(node2)});
1000+
{toString(n1), toString(n2)},
1001+
{InstNode.info(n1), InstNode.info(n2)});
9951002
then
9961003
fail();
9971004
end matchcontinue;

0 commit comments

Comments
 (0)