Encode enum cases without associated values#158
Conversation
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. |
Sources/PluginCore/Variables/Enum/Switcher/TaggedEnumSwitcherVariable.swift
Show resolved
Hide resolved
| generatedCode | ||
| } | ||
| } else { | ||
| preSyntax("\(values.first!)") |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
I changed nothing in the decoding part and there there is also an unused variable so this seems like skewed standards but I have fixed this.
@Codable
@IgnoreCodingInitialized
enum SomeEnum {
case bool(_ variableBool: Bool = true)
}this previously encoded to nothing which means now all the tests fail with diff: extension SomeEnum: Encodable {
func encode(to encoder: any Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
switch self {
case .bool(_: _):
+ let _ = container.superEncoder(forKey: CodingKeys.bool)
- breakand it is unclear to me whether this is expected behavior from |
|
I believe the previous behavior of |
Fixes #157
This breaks some
@IgnoreCodingInitializedtests 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.