Skip to content

Support reference to constants as disjunction discriminators #788

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
K-Phoen opened this issue Apr 1, 2025 · 0 comments · May be fixed by #789
Open

Support reference to constants as disjunction discriminators #788

K-Phoen opened this issue Apr 1, 2025 · 0 comments · May be fixed by #789
Assignees

Comments

@K-Phoen
Copy link
Member

K-Phoen commented Apr 1, 2025

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)

@spinillos spinillos self-assigned this Apr 1, 2025
@spinillos spinillos linked a pull request Apr 8, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants