Skip to content

Commit

Permalink
Better error for duplicate mods in new inst.
Browse files Browse the repository at this point in the history
  • Loading branch information
perost authored and OpenModelica-Hudson committed Nov 21, 2016
1 parent 2c7afbd commit dc38639
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 2 additions & 0 deletions Compiler/NFFrontEnd/NFInst.mo
Expand Up @@ -360,6 +360,8 @@ algorithm
for c in components loop
if Component.isNamedComponent(ComponentNode.component(c)) then
// TODO: Handle components with the same name.
// TODO: If duplicate components should be handled here, also
// remove them from the list of components.
scope := ClassTree.add(scope, ComponentNode.name(c),
ClassTree.Entry.COMPONENT(idx), ClassTree.addConflictReplace);
end if;
Expand Down
10 changes: 6 additions & 4 deletions Compiler/NFFrontEnd/NFMod.mo
Expand Up @@ -193,6 +193,7 @@ public
algorithm
info := match modifier
case MODIFIER() then modifier.info;
case REDECLARE() then SCode.elementInfo(modifier.element);
else Absyn.dummyInfo;
end match;
end info;
Expand Down Expand Up @@ -448,12 +449,13 @@ protected
then
mod2;

// Both modifiers have bindings, give duplicate modification error.
case (MODIFIER(), MODIFIER())
// Both modifiers modify the same element, give duplicate modification error.
else
algorithm
comp_name := stringDelimitList(listReverse(mod1.name :: prefix), ".");
comp_name := stringDelimitList(listReverse(Modifier.name(mod1) :: prefix), ".");
Error.addMultiSourceMessage(Error.DUPLICATE_MODIFICATIONS,
{comp_name, ModifierScope.toString(scope)}, {mod1.info, mod2.info});
{comp_name, ModifierScope.toString(scope)},
{Modifier.info(mod1), Modifier.info(mod2)});
then
fail();

Expand Down

0 comments on commit dc38639

Please sign in to comment.