Least and greatest value of empty enumeration
The grammar allows an enumeration to not have any literals (by making the enum-list optional), but why?
short-class-specifier :
IDENT "=" base-prefix type-specifier [ array-subscripts ]
[ class-modification ] description
| IDENT "=" enumeration "(" ( [ enum-list ] | ":" ) ")" description
As long as it is allowed we have a problem with models like this, where the greatest value of the enumeration is needed:
model EmptyEnumeration
type E = enumeration();
parameter Integer n = 0;
Integer k = Integer(min({ E(i) for i in 1:n }));
end EmptyEnumeration;
OpenModelica doesn't follow the grammar here and gives a syntax error for the empty enumeration. But I guess that just confirms that there shouldn't be any issue with making enum-list required.
As I recall one issue with enumerations was sub/super-typing, and there were some discussions about being able to add enumeration members later. That was then restricted to just using enumeration(:) as constraining type - and one guess would be that enumeration() was an early variant of that.
I realized that with replaceable enumerations there might be a use-case:
model M
replaceable type E=enumeration(:);
Real x[E](each start=0);
equation
der(x)=ones(size(x,1))-x;
end M;
M m1(redeclare type E=enumeration());
M m2(redeclare type E=enumeration(A, B));
For examples, if someone wants to have trace-products with names it might make sense to allow none as well.
For some reason Dymola generates 0 as minimum for the missing enumeration.