Closed NeroBlackstone closed 6 months ago
A similar julia 1.10 test fail is No.37 in same test file.
Case №37: Deserialization Number to Number: Test Failed at /home/nero/github/Serde.jl/test/deser.jl:662
Expression: Serde.deser_json(Message{Nothing}, exp_str)
Expected: "WrongType: for 'Message{Nothing}' value 'Dict{String, Any}()' has wrong type 'payload::Dict{String, Any}', must be 'payload::Nothing'"
Message: "cannot convert a value to nothing for assignment"
Stacktrace:
[1] macro expansion
@ ~/github/Serde.jl/test/deser.jl:662 [inlined]
[2] macro expansion
@ ~/.julia/juliaup/julia-1.10.3+0.x64.linux.gnu/share/julia/stdlib/v1.10/Test/src/Test.jl:1577 [inlined]
[3] macro expansion
@ ~/github/Serde.jl/test/deser.jl:655 [inlined]
[4] macro expansion
@ ~/.julia/juliaup/julia-1.10.3+0.x64.linux.gnu/share/julia/stdlib/v1.10/Test/src/Test.jl:1577 [inlined]
[5] top-level scope
@ ~/github/Serde.jl/test/deser.jl:7
Hi, @NeroBlackstone! I've seen this issue before and I have not been able to pinpoint the root cause. If you do plain conversion, outside of the package, it will work just fine. This behaviour sprung up after 1.10 release.
Currently it tries to convert after return (there's a specific syntax for that). I think, the solution would be to switch to explicit conversion within functions before return.
I find the reason, convert()
throws inconsistent errors in Julia 1.10.
I think the simplest solution is:
elseif (e isa MethodError) || (e isa InexactError) || (e isa ArgumentError) || (e isa ErrorException)
I have tested it and all passed, what do you think?
Have you tried explicit conversions? I think it might take more time but be more sustainable in the long run.
Also I'm baffled by the policy. It's not julia 2.0 to break existing error behaviours)
Also, @gryumov what's your stand on this? Apparently, there's an issue already on the official page.
Also I'm baffled by the policy. It's not julia 2.0 to break existing error behaviours)
“Error types, unless explicitly documented (like DomainError or Base.IOError), are subject to change is the official policy”
Looks like they don't think this is a break change.😅
I don’t know if subsequent Julia versions will maintain this behavior.
I think, the solution would be to switch to explicit conversion within functions before return.
Sorry, I don't quite understand what you are describing here. Do you mean to explicitly call the convert
function to convert Any
type to Missing
before the derse
function returns?
Or define a new convert
function to throw MethodError
?
Okay, I see where the issue is. I'm taking a look. You can comment out these tests if you're actively developing. They don't affect the core functionality.
Hello everyone! @dmitrii-doronin it might seem strange #40, but we need to deal with multiple dispatch, let's create issues for this:
https://github.com/bhftbootcamp/Serde.jl/actions/runs/8912634371/job/24476466918?pr=40
In
test/deser.jl
, test case No.30:In julia 1.10, it will fail:
This is because Julia 1.10 throw a different Error in
src/de/deser.jl
:If we test this function:
Julia 1.10 will throw
ERROR: cannot convert a value to missing for assignment
Julia 1.8 will throw
ERROR: MethodError: convert(::Type{Union{}}, ::Int64) is ambiguous. Candidates
And in
src/de/deser.jl
, we are not handlingErrorException
.Question
How do you think it can be improved better? I can open a PR.