Skip to content
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

Generate referenced enum defaults correctly #35

Closed
sdboyer opened this issue Oct 7, 2021 · 3 comments · Fixed by #48
Closed

Generate referenced enum defaults correctly #35

sdboyer opened this issue Oct 7, 2021 · 3 comments · Fixed by #48
Assignees
Labels
kind/bug Something isn't working

Comments

@sdboyer
Copy link
Contributor

sdboyer commented Oct 7, 2021

Currently, when there's an enum with a default value that's referenced, we generate the reference to it like this:

CUE TS
package cuetsy

AutoCamel: *"foo" | "bar" @cuetsy(kind="enum")
Ref: {
  ac: AutoCamel
} @cuetsy(kind="interface")
export enum AutoCamel {
  Foo = "foo",
  Bar = "bar",
}

export const defaultAutoCamel: AutoCamel = AutoCamel.Foo

export interface Ref {
  ac: AutoCamel
}

export const defaultRef: Ref = {
  ac: "foo"
}

This fails typechecking. The default should be:

export const defaultRef: Ref = {
  ac: AutoCamel.Foo
}

This (disabled) test contains a more exhaustive set of cases to check, but they all ultimately amount to the same problem.

@sdboyer sdboyer added the kind/bug Something isn't working label Oct 7, 2021
@sdboyer
Copy link
Contributor Author

sdboyer commented Oct 7, 2021

fyi @ryantxu

@sh0rez
Copy link
Member

sh0rez commented Nov 19, 2021

sorta blocked on cue-lang/cue#1389

@sdboyer
Copy link
Contributor Author

sdboyer commented Nov 20, 2021

Note - OP is not actually quite true. We do fine with the basic case. Things get screwy when we try to rely on attributes through various combinations of intermediate unification and reference.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants