Skip to content

UnNamed discriminant unions #31

@choubacha

Description

@choubacha

This may be known behavior but it appears that un-named union types fail:

struct SomeStruct
{
    union switch (int v)
    {
    case 1:
      void;
    }
    value;
};

outputs:

Failed: can't have unnamed type Union(Named("v", Int), [UnionCase(Const(1), Void)], None)

It doesn't look like the RFC specifies that this is needed though.


      type-specifier:
           [ "unsigned" ] "int"
         | [ "unsigned" ] "hyper"
         | "float"
         | "double"
         | "quadruple"
         | "bool"
         | enum-type-spec
         | struct-type-spec
         | union-type-spec
         | identifier
...
      union-type-spec:
         "union" union-body

      union-body:
         "switch" "(" declaration ")" "{"
            case-spec
            case-spec *
            [ "default" ":" declaration ";" ]
         "}"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions