DDS-XTypes 1.0 FTF Avatar
  1. OMG Issue

DDSXTY_ — Incorrect union assignability rules

  • Key: DDSXTY_-15
  • Legacy Issue Number: 16366
  • Status: closed  
  • Source: Real-Time Innovations ( Mr. Alejandro Campos)
  • Summary:

    The type assignability rules for unions have a number of problems (see the UNION_TYPE row of the table in section 7.2.4.5, Aggregation Types):

    · The second and third bullets in the list of rules are redundant.

    · According to the fourth bullet (assignability of default members), a union with a default label may not even be assignable to itself.

    · The rules do not account for member IDs and names, which can be significant when deserializing objects in some data representations.

    · The rules do not account for the fact that the discriminator may or may not be a key.

    · The rules do not account for extensibility kind.

    · The rules are under-specified with respect to malformed samples. Specifically, the discriminator may select a particular member X of the union, but the implementation may discover in its place a different member Y. (This situation will be detectable only with certain data representations.)

    Proposed Resolution:

    Apply the followin rules:

    · Apply the member ID, name, and type matching rules for structures to unions as well.

    · Every discriminator value in T2 must select the “same” member in T1—or no member at all. This can be checked in three steps:

    1. Every discriminator value in a non-default label of T2 selects the same member in T1 or none at all.

    2. Every discriminator value in a non-default label of T1 selects the same member in T2 or none at all.

    3. If both T1 and T2 have a default label, the corresponding members must be assignable.

    · Either both types must have a key or neither.

    · The extensibility kinds must match.

    · Specify explicitly that an object of a union with a mismatch between its discriminator and non-discriminator members is considered malformed. The impact is unspecified, although implementations may consider the object unassignable.

    Proposed Revised Text:

    Replace the center column of the UNION_TYPE row of the table in section 7.2.4.5, Aggregation Types, with the following:

    UNION_TYPE if and only if it is possible to unambiguously identify the appropriate T1 member based on the T2 discriminator value and to transform both the discriminator and the other member correctly. Specifically:

    · T1.discriminator.id == T2.discriminator.id and T1.discriminator.type is-assignable-from T2.discriminator.type.

    · Either the discriminators of both T1 and T2 are keys or neither are keys.

    · Any members in T1 and T2 that have the same name also have the same ID and any members with the same ID also have the same name.

    · For each member “m1” in T1, if there is a member m2 in T2 with the same member ID then m1.type is-assignable-from m2.type.

    · T1.extensibility == T2.extensibility.

    · A discriminator value appearing in a non-default label of T2 selects a member m2. If the same discriminator value selects a member m1 of T1, then m1.id == m2.id.

    · A discriminator value appearing in a non-default label of T1 selects a member m1. If the same discriminator value selects a member m2 of T2, then m1.id == m2.id.

    · If both T1 and T2 have a default label, then the IDs of the members selected by those labels must be equal.

    AND if T1 is final, the number of members in T1 is equal to the number of members in T2.

    Remove the footnote that is linked to the old contents of that table cell.

    Append the following paragraphs to the right-hand column of the same table row:

    If either member of the union is unassignable, then the T2 object is unassignable to T1.

    If the discriminator value of a union object and its non-discriminator member do not agree with one another, the object is considered malformed. In such a case, the behavior is unspecified. In particular, the implementation may or may not be able to detect this error. If it can, it should consider the object unassignable.

  • Reported: DDS-XTypes 1.0b2 — Tue, 5 Jul 2011 04:00 GMT
  • Disposition: Resolved — DDS-XTypes 1.0
  • Disposition Summary:

    Apply the following rules:
    • Apply the member ID, name, and type matching rules for structures to unions as well.
    • Every discriminator value in T2 must select the “same” member in T1—or no member at all. This can be checked in three steps:
    1. Every discriminator value in a non-default label of T2 selects the same member in T1 or none at all.
    2. Every discriminator value in a non-default label of T1 selects the same member in T2 or none at all.
    3. If both T1 and T2 have a default label, the corresponding members must be assignable.
    • Either both types must have a key or neither.
    • The extensibility kinds must match.
    • Specify explicitly that an object of a union with a mismatch between its discriminator and non-discriminator members is considered malformed. If an implementation is able to detect this case, it shall consider the object unassignable. If not, then the impact is unspecified.

  • Updated: Fri, 6 Mar 2015 21:48 GMT