DOCGroup / ACE_TAO

ACE and TAO
https://www.dre.vanderbilt.edu/~schmidt/TAO.html
701 stars 381 forks source link

Illegal IDL union accepted by tao_idl #2279

Open jwillemsen opened 2 months ago

jwillemsen commented 2 months ago

The following IDL is illegal but accepted by tao_idl, ridlc rejects it with IDL::ParseError: 'default' case label superfluous for IDL::AST::Union UnionTypeTest

module Test {
enum TypeKind {
STRING_TYPE,
LONG_TYPE,
FLOAT_TYPE
};

union UnionTypeTest switch(TypeKind) {
case STRING_TYPE:
    string string_data;
case LONG_TYPE:
    long long_data;
case FLOAT_TYPE:
    float float_data;
default:
    boolean default_data;
};

};
jwillemsen commented 2 months ago

Coming from https://github.com/OpenDDS/OpenDDS/discussions/4782

iguessthislldo commented 2 months ago

It's a weird case, but I'm not seeing something in the IDL spec that explicitly disallows this.

mitza-oci commented 2 months ago

It's a weird case, but I'm not seeing something in the IDL spec that explicitly disallows this.

It was in IDL v3 https://www.omg.org/spec/CORBA/3.3/Interfaces/PDF, I'm not sure why IDL v4 dropped it

iguessthislldo commented 2 months ago

A union type can contain a default label only where the values given in the non-default labels do not cover the entire range of the union's discriminant type.

This? I see it in 4.2 now, it moved into the bottom of the first "Note" in the union section. Alright, so it does explicitly disallow this, assuming "range" is all the valid enum values and not just the underlying integer type.

mitza-oci commented 2 months ago

Right, so I guess I just didn't find it in 4.2. The union discriminator is defined by the enum type, not the underlying type.