Closed EliteMasterEric closed 1 year ago
I rewrote it to this and it seems to work:
if (field.meta.has(':optional')) {
switch (field.type) {
case TAbstract(t, params):
if (t.toString() == "Null") {
// Null<Bool>
skips.push(macro $f_a == null);
} else {
// Bool
skips.push(macro false);
}
default:
skips.push(macro $f_a == null);
}
} else {
skips.push(macro false);
}
Thanks.
I think at some point the compiler treated @:optional as Null<> fields but it must have changed.
Something like:
causes a compilation error:
The issue appears to be with the writer interpreting the
@:optional
and assuming that means the underlying field is nullable, when actually@:optional
is for the parser.Note this issue would only happen on basic fields unless null safety was enabled.
This could be solved by ignoring
@:optional
on the writer if the field is a basic type that isn't nullable.Let me know if you need a more thorough reproduction.