-
Notifications
You must be signed in to change notification settings - Fork 3
add parsing for cases where node or argument is missing #12
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
base: main
Are you sure you want to change the base?
add parsing for cases where node or argument is missing #12
Conversation
|
Actually this still doesn't handle the case where the type is both nested and nilable 🤔 {% else %}
%child = node.child?({{value[:name]}})
%var{name} = if %child
{{value[:type]}}.from_kdl(%child)
else
{% if value[:has_default] %}
{{value[:default]}}
{% elsif value[:nilable] %}
nil
{% else %}
raise SerializableException.new("Missing argument for KDL node: {{name}}")
{% end %}
end
(MissingArgumentWithDefault | Nil).from_kdl(__temp_3430)if the ivar is nilable, the type includes |
|
@BigBoyBarney can you not use if %child
{{(value[:type].union_types - [Nil]).first}}.from_kdl(%child)
else
...of course we might have to loop through all union types and attempt |
|
I can check tonight but I don't think so because we need to cleanly handle the I solved it in this commit by implementing Types that can be initalised from kdl should have the method already, and types that don't will result in a comptime error so it's pretty nice. Credits to Hertzdevil for the idea. I'll add a few more tests tonight to make sure I didn't miss anything and prettify the specs a bit. |
|
Won't |
|
Nope! :D HOWEVER, it attempts to call I'll make this PR a draft, I have a long day tomorrow but I can flesh this out over the weekend! :D Will probably have to introduce some kind of pull parser from Sorry about the notification spam lately! |
|
Can we not just extend |
|
We totally could! That would be the simplest solution for sure, but I thought maybe we could unify all the Will have to play around with it a bit to see if there's a compelling reason for it though, if not, we can just define |
|
I think we should try |
|
Nvm I was wrong the last time, KDL's equivalent of a |
|
Okay so turns out I was wrong again 🤣 Thankfully, we don't need to do any of that basic type extension just yet, as This PR is now ready for review, I added a bunch of tests, too, so it should be fine (I hope). This PR only implements the missing / default logic for Aparte: I added a pending spec for the deserialize / serialize round trip because that was incorrectly passing on main. See #13 for more detail. |
Fixes #11
This only adds parsing capabilities for missing child-argument unwraps. I'll probably get to the others eventually too, but this is what I currently (urgently) needed :P