Inconsistent diagram and error behavior on double define name

0 votes
asked Jul 8 in Bug by Sören

Hello,

I came across inconsistent behavior when double (or even more) defining a name.

My expected behavior is that plantuml always throws an error if I want to declare an element twice. But it only does I sometimes, not in this case.

In the example (1) below we see, that plantuml throws an error here, but only on the last line, when the uml object is declared with the same name. All lines before are processed fine, but why?

(1) http://www.plantuml.com/plantuml/uml/5On13e0W30JllA8tp_w0hs1T8mPAqfReywMNtKmocMnUr6TlYLin8zvJ5OTUXH40cJr-8y7drAg0_1wlhGL1TMWQnmFsi3BaNAqV

  1. class c1 gets declared --> created // ok
  2. interface c1 gets declared --> c1 transformed into an interface // I would expect an exception here
  3. enum c1 gets declared -->  c1 transformed into an enum// I would expect an exception here
  4. object c1 gets declare --> error // why now and not before?

I' debugged this example with the current version of plantuml and found the different treating of the input code.

In CommandCreateEntityObject.java, method executeArg(...), which is called when the object is added, you simply throw an error when the name is already defined. (what I expect in general).

For all "class-diagram types" like interfaces and enums you are doing this change "type of the class" approach (step 2 and 3 in the exampe) on purpose: in CommandCreateClass.java, method executeArg(...), you reuse the Entity from the list and just change the type if the leaf is already contained.

My suggestion would be to simply throw an exception here as well.

I can also create this (2) here, which should be not ok ;-)

(2) http://www.plantuml.com/plantuml/uml/SoWkIImgAStDuKhEIImkLaWsLAZcqbN8JSrDIYqovAhboimhIIrAIqnE1KfnLNDv9kVdfheLvUU6PAHwmgLi5KoCW6fJyqfp8SeSyr8ySntpN442gI1Z75BpKe2s0000

Best regards,

Sören

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:

[Antispam2 Feature: please please wait 1 or 2 minutes (this message will disappear) before pressing the button otherwise it will fail](--------)
To avoid this verification in future, please log in or register.
...