You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Optional Fields in toStruct do not get null value #171
I'd accept a PR with the Possible Solution fix. I'm not sure the API as-written is in a state that I'm completely happy with, given that nullability and gracefully handling type mismatches are fundamental differences between Zig and Lua, but it seems clear that null is intended in this situation and should not require a default value.
That's a good point - on the lua side all the following are equivalent:
A= {a=undefined_variable};
B= {a=nil};
C= {};
So actually defaulting optionals to null might be a footgun that will cover issues in the lua code. However, this is an issue even when default value exists, and I think people usually expect implicit null when using optionals.
I come to think the solution above is the best option. I'll probably submit the PR later this week
Activity
[-]Optional Fields in toStruct[/-][+]Optional Fields in toStruct do not get null value[/+]robbielyman commentedon Aug 11, 2025
I'd accept a PR with the Possible Solution fix. I'm not sure the API as-written is in a state that I'm completely happy with, given that nullability and gracefully handling type mismatches are fundamental differences between Zig and Lua, but it seems clear that
nullis intended in this situation and should not require a default value.tmrlvi commentedon Aug 17, 2025
That's a good point - on the
luaside all the following are equivalent:So actually defaulting optionals to
nullmight be a footgun that will cover issues in the lua code. However, this is an issue even when default value exists, and I think people usually expect implicitnullwhen using optionals.I come to think the solution above is the best option. I'll probably submit the PR later this week