Skip to content

Encode enum cases without associated values#158

Open
Amzd wants to merge 3 commits intoSwiftyLab:mainfrom
Amzd:main
Open

Encode enum cases without associated values#158
Amzd wants to merge 3 commits intoSwiftyLab:mainfrom
Amzd:main

Conversation

@Amzd
Copy link

@Amzd Amzd commented Feb 7, 2026

Fixes #157

This breaks some @IgnoreCodingInitialized tests but that API is too confusing for me. I have no idea what it is actually supposed to do, so I can't tell if the failing tests are actually breaking the intended use. A maintainer needs to look at that.

@soumyamahunt
Copy link
Contributor

This breaks some @IgnoreCodingInitialized tests but that API is too confusing for me. I have no idea what it is actually supposed to do, so I can't tell if the failing tests are actually breaking the intended use. A maintainer needs to look at that.

Can you provide what is the error you getting? The change seems to be in the right direction. So the tests might need to be updated with latest data.

}
} else {
preSyntax("\(values.first!)")
"break"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: You can add logic to conditionally include this break syntax depending on whether preSyntax returns any syntax.

}
}

struct WithoutAssociatedVariables {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: You can add test case for your original example as well, without the CodedAt. You can add it to CodableTests

generatedCode
}
} else {
preSyntax("\(values.first!)")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this will cause unused variable warnings in case of your original example. Can you address that in someway? May be passing some flag to this preSyntax closure and customizing the output based on this flag?

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 this pull request may close these issues.

[Bug] enum cases are not encoded unless type specified

2 participants