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?
- class c1 gets declared --> created // ok
- interface c1 gets declared --> c1 transformed into an interface // I would expect an exception here
- enum c1 gets declared --> c1 transformed into an enum// I would expect an exception here
- 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 ;-)