Skip to content
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

no matching method found isless(::Int64, ::Nothing): isless(x::Int64, y::Nothing) #456

Closed
lgeissbauer-btig opened this issue Jan 12, 2023 · 3 comments

Comments

@lgeissbauer-btig
Copy link

julia> struct A
       a::Union{Int,Nothing}
       end

julia> function b(a::A)
       !isnothing(a.a) && 1 < a.a
       end
b (generic function with 1 method)

julia> JET.@report_call b(A(1))
═════ 1 possible error found ═════
┌ @ REPL[9]:2 1 < a.a
│┌ @ operators.jl:356 isless(x, y)
││ no matching method found `isless(::Int64, ::Nothing)`: isless(x::Int64, y::Nothing)
│└────────────────────


julia> b(A(1))
false

ref:
JuliaTime/TimeZones.jl#424

@aviatesk
Copy link
Owner

Fixed on Julia 1.10 and higher.

@dpinol
Copy link
Contributor

dpinol commented Jan 12, 2023

the workaround I use for this is

function b(a::A)
       !isnothing(a.a) && 1 < something(a).a
end 

@lgeissbauer-btig
Copy link
Author

julia> function b1(a::A)
       a.a isa Int && 1 < a.a::Int
       end
b1 (generic function with 1 method)

julia> JET.@report_call b1(A(1))
No errors detected

also works. But I'm looking forward to 1.10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants