From d4faaeb63b8381532dcff9cf11de3aa51b5fc9c8 Mon Sep 17 00:00:00 2001 From: Brian Chen Date: Sat, 25 Feb 2023 20:07:39 -0800 Subject: [PATCH 1/3] Don't use zerolike fallback for GlobalRefs This was causing UndefRefErrors on nightly. --- src/forward/lib.jl | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/forward/lib.jl b/src/forward/lib.jl index a5518fd5d..fecbd90e2 100644 --- a/src/forward/lib.jl +++ b/src/forward/lib.jl @@ -9,6 +9,9 @@ end # TODO figure out why this made a test fail zerolike(x::Union{Module,Type}) = nothing +# Required to not get an UndefRefError on 1.10 +zerolike(x::GlobalRef) = nothing + # TODO: `@non_differentiable` and `@linear` @tangent zerolike(x) = zerolike(x), _ -> zerolike(x) From eda7f3862ffd6d6c69c9ca935e82d0ada5009793 Mon Sep 17 00:00:00 2001 From: Brian Chen Date: Sun, 26 Feb 2023 09:10:16 -0800 Subject: [PATCH 2/3] fix now passing backtrace test on nightly --- test/compiler.jl | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/test/compiler.jl b/test/compiler.jl index 198ca2a29..a74da5433 100644 --- a/test/compiler.jl +++ b/test/compiler.jl @@ -17,8 +17,10 @@ trace_contains(st, func, file, line) = any(st) do fr end bad(x) = x +const bad_def_line = (@__LINE__) + 1 @adjoint bad(x) = x, Δ -> error("bad") +const bad_call_line = (@__LINE__) + 3 function badly(x) x = x + 1 x = bad(x) @@ -30,11 +32,11 @@ y, back = pullback(badly, 2) @test_throws Exception back(1) bt = try back(1) catch e stacktrace(catch_backtrace()) end -@test trace_contains(bt, nothing, "compiler.jl", 20) -if VERSION >= v"1.6-" - @test_broken trace_contains(bt, :badly, "compiler.jl", 24) +@test trace_contains(bt, nothing, "compiler.jl", bad_def_line) +if VERSION <= v"1.6-" || VERSION >= v"1.10-" + @test trace_contains(bt, :badly, "compiler.jl", bad_call_line) else - @test trace_contains(bt, :badly, "compiler.jl", 24) + @test_broken trace_contains(bt, :badly, "compiler.jl", bad_call_line) end # Type inference checks From 14120e94e443aeb222df28328a08b75225f48976 Mon Sep 17 00:00:00 2001 From: Brian Chen Date: Sun, 26 Feb 2023 14:30:41 -0800 Subject: [PATCH 3/3] more robust test for Pullback show --- test/compiler.jl | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/test/compiler.jl b/test/compiler.jl index a74da5433..c9b091f78 100644 --- a/test/compiler.jl +++ b/test/compiler.jl @@ -83,10 +83,14 @@ y, back = @test_inferred pullback(((a,b),) -> a, (5, 10)) # testcase for issue #808 # testing that methods(Base.show) does not throw. Having something more specific would be too fragile -buf = IOBuffer() -Base.show(buf, methods(Base.show)) -str_repr = String(take!(buf)) -@test !isempty(str_repr) +show_err = try + buf = IOBuffer() + Base.show(buf, methods(Base.show)) + nothing +catch ex + ex +end +@test show_err === nothing struct Funky x