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
json.unmarshal seems to be ignoring alternative structs in a union, because if it doesn't find the fields it's looking for on the first struct variant it tries, it parses it as any value, skipping the other possibilities.
So this is actually tricky to handle correctly because it has to do a best fit search, and currently it does the "first fit" search. In the case other structs, a missing field might not be an error, so it just gets ignored.
Context
json.unmarshal
seems to be ignoring alternative structs in a union, because if it doesn't find the fields it's looking for on the first struct variant it tries, it parses it as any value, skipping the other possibilities.Odin/core/encoding/json/unmarshal.odin
Lines 461 to 474 in 5b6c96c
Expected Behavior
JSON unmarshalling to
B
instead ofA
, or some sort of error/advisory/workaround.Current Behavior
Invalid type assertion from U to B, actual type: A
Failure Information (for bugs)
Steps to Reproduce
The text was updated successfully, but these errors were encountered: