Skip to content

Support reference to constants as disjunction discriminators #788

@K-Phoen

Description

@K-Phoen

Given the following schema, cog should be able to correctly infer a discriminator and the associated discrimination mapping:

Layout: GridLayoutKind | RowsLayoutKind

#GridLayoutKindType: "GridLayout"

GridLayoutKind: {
    kind: #GridLayoutKindType & "GridLayout"
    // kind: #GridLayoutKindType // ← this should work too
    gridLayoutProperty: string
}

#RowsLayoutKindType: "RowsLayout"

RowsLayoutKind: {
    kind: #RowsLayoutKindType & "RowsLayout"
    // kind: #RowsLayoutKindType // ← this should work too
    rowsLayoutProperty: string
}

Today, the kind field in RowsLayoutKind and GridLayoutKind is not used as a discriminator because it is incorrectly parsed as a reference instead of a "constant reference".

This should be fixed and we need to make sure that once it is, we generate valid code for the resulting disjunction (especially in Go)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions