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

Allow value enums to be variants of type enums #1496

Closed
worstell opened this issue May 15, 2024 · 0 comments
Closed

Allow value enums to be variants of type enums #1496

worstell opened this issue May 15, 2024 · 0 comments
Assignees

Comments

@worstell
Copy link
Contributor

//ftl:enum
type TypeEnum interface {
  typeEnum()
}

type ValueEnumType ValueEnum
func (ValueEnumType) typeEnum() {}


//ftl:enum
type ValueEnum string

const (
  A ValueEnum = "a"
)

should be extracted as:

enum ValueEnum: String {
   A = "a"
} 

enum TypeEnum {
   ValueEnumType foo.ValueEnum
}

right now, it extracts as the following:

enum ValueEnum: String {
   A = "a"
} 

enum TypeEnum {
   ValueEnumType string
}

however, this pattern will remain erroneous:

//ftl:enum
type TypeEnum interface {
  typeEnum()
}

//ftl:enum
type ValueEnum string
func (ValueEnum) typeEnum() {}

const (
  A ValueEnum = "a"
)

because ValueEnum cannot be both a type variant name and itself a value enum. we do not support mixing of type and value variants in a single enum

@worstell worstell self-assigned this May 15, 2024
worstell added a commit that referenced this issue May 18, 2024
small changes + fixes preempting the refactor

fixes #1531, #1527, #1496
matt2e pushed a commit that referenced this issue May 23, 2024
small changes + fixes preempting the refactor

fixes #1531, #1527, #1496
matt2e added a commit that referenced this issue May 23, 2024
Un-reverting #1535 by @worstell 
small changes + fixes preempting the refactor

fixes #1531,
#1527,
#1496

Co-authored-by: worstell <[email protected]>
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

No branches or pull requests

1 participant