From 66ef0f3566fae94f6af8da6f91dae7e36179cba6 Mon Sep 17 00:00:00 2001 From: William Moses Date: Mon, 30 Sep 2024 13:37:50 -0500 Subject: [PATCH] Fix error exception (#1931) * Fix error exception * fix --------- Co-authored-by: William Moses --- src/Enzyme.jl | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Enzyme.jl b/src/Enzyme.jl index aa018ea23b..17a7c6ff5d 100644 --- a/src/Enzyme.jl +++ b/src/Enzyme.jl @@ -682,15 +682,19 @@ code, as well as high-order differentiation. if A isa UnionAll rt = Compiler.primal_return_type(rmode, Val(world), FTy, tt) - A2 = A{rt} + rt = Core.Compiler.return_type(f.val, tt) + A2 = A{rt} + if rt == Union{} + throw(ErrorException("Return type inferred to be Union{}. Giving up.")) + end else @assert A isa DataType rt = A + if rt == Union{} + throw(ErrorException("Return type inferred to be Union{}. Giving up.")) + end end - if rt == Union{} - error("Return type inferred to be Union{}. Giving up.") - end ModifiedBetweenT = falses_from_args(Nargs + 1) ModifiedBetween = Val(ModifiedBetweenT)