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

Commit dc38639

Browse files
perostOpenModelica-Hudson
authored andcommitted
Better error for duplicate mods in new inst.
1 parent 2c7afbd commit dc38639

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

Compiler/NFFrontEnd/NFInst.mo

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,8 @@ algorithm
360360
for c in components loop
361361
if Component.isNamedComponent(ComponentNode.component(c)) then
362362
// TODO: Handle components with the same name.
363+
// TODO: If duplicate components should be handled here, also
364+
// remove them from the list of components.
363365
scope := ClassTree.add(scope, ComponentNode.name(c),
364366
ClassTree.Entry.COMPONENT(idx), ClassTree.addConflictReplace);
365367
end if;

Compiler/NFFrontEnd/NFMod.mo

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ public
193193
algorithm
194194
info := match modifier
195195
case MODIFIER() then modifier.info;
196+
case REDECLARE() then SCode.elementInfo(modifier.element);
196197
else Absyn.dummyInfo;
197198
end match;
198199
end info;
@@ -448,12 +449,13 @@ protected
448449
then
449450
mod2;
450451

451-
// Both modifiers have bindings, give duplicate modification error.
452-
case (MODIFIER(), MODIFIER())
452+
// Both modifiers modify the same element, give duplicate modification error.
453+
else
453454
algorithm
454-
comp_name := stringDelimitList(listReverse(mod1.name :: prefix), ".");
455+
comp_name := stringDelimitList(listReverse(Modifier.name(mod1) :: prefix), ".");
455456
Error.addMultiSourceMessage(Error.DUPLICATE_MODIFICATIONS,
456-
{comp_name, ModifierScope.toString(scope)}, {mod1.info, mod2.info});
457+
{comp_name, ModifierScope.toString(scope)},
458+
{Modifier.info(mod1), Modifier.info(mod2)});
457459
then
458460
fail();
459461

0 commit comments

Comments
 (0)