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

Reused enum type not schema extracted correctly #2857

Open
tomdaffurn opened this issue Sep 27, 2024 · 0 comments
Open

Reused enum type not schema extracted correctly #2857

tomdaffurn opened this issue Sep 27, 2024 · 0 comments
Labels
bug Something isn't working go Go runtime next Work that will be be picked up next P1

Comments

@tomdaffurn
Copy link
Contributor

tomdaffurn commented Sep 27, 2024

When a type is used in 2 Go enums, the schema has that type missing from one of the enums. It's non-deterministic which enum loses.

//ftl:enum
type Animal interface{ animal() }
type Lion struct{}
type Dog struct{}

func (Lion) animal() {}
func (Dog) animal() {}

//ftl:enum
type Pet interface{ pet() }
type Cat struct{}

func (Cat) pet() {}
func (Dog) pet() {}

Will create either of these schemas:

  export enum Animal {
    Lion example.Lion
    Dog example.Dog
  }
  export enum Pet {
    Cat example.Cat
  }

☝️ Pet.Dog is missing

or:

  export enum Animal {
    Lion example.Lion
  }
  export enum Pet {
    Cat example.Cat
    Dog example.Dog
  }

☝️ Animal.Dog is missing

@tomdaffurn tomdaffurn added bug Something isn't working go Go runtime labels Sep 27, 2024
@github-actions github-actions bot added the triage Issue needs triaging label Sep 27, 2024
@ftl-robot ftl-robot mentioned this issue Sep 27, 2024
@tomdaffurn tomdaffurn changed the title Broken enum schema extraction Reused enum type not schema extracted correctly Sep 27, 2024
@gak gak added next Work that will be be picked up next P1 and removed triage Issue needs triaging labels Sep 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working go Go runtime next Work that will be be picked up next P1
Projects
None yet
Development

No branches or pull requests

2 participants