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

try/catch error message regression #1546

Open
CarloLucibello opened this issue Dec 30, 2024 · 1 comment
Open

try/catch error message regression #1546

CarloLucibello opened this issue Dec 30, 2024 · 1 comment

Comments

@CarloLucibello
Copy link
Member

We used to have a nice error message for differentiating through try/catch block, saying "Can't differentiate function execution in catch block". On julia v1.11, we have a cryptic "unreachable" error instead:

julia> function try_catch_finally(cond, x)
    try
        x = 2x
        cond && throw(DomainError())
    catch
        x = 2x
    finally
        x = 3x
    end
    x
end

julia> res, pull = pullback(try_catch_finally, true, 1.)
(12.0, Zygote.var"#78#79"{Zygote.Pullback{Tuple{typeof(try_catch_finally), Bool, Float64}, Any}}((try_catch_finally)))

julia> pull(1)
ERROR: unreachable
Stacktrace:
 [1] error(s::String)
   @ Base ./error.jl:35
 [2] try_catch_finally
   @ ./REPL[12]:8 [inlined]
 [3] (::Zygote.Pullback{Tuple{typeof(try_catch_finally), Bool, Float64}, Any})(Δ::Int64)
   @ Zygote ~/.julia/dev/Zygote/src/compiler/interface2.jl:0
 [4] (::Zygote.var"#78#79"{Zygote.Pullback{Tuple{typeof(try_catch_finally), Bool, Float64}, Any}})(Δ::Int64)
   @ Zygote ~/.julia/dev/Zygote/src/compiler/interface.jl:91
 [5] top-level scope
   @ REPL[16]:1
@ToucheSir
Copy link
Member

I think it's because try-catch is supported in a limited fashion after #1474, but this hits an edge case that didn't cover. @Pangoraw have you seen this before?

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

2 participants