Skip to content

Error: improve no type error message#2719

Merged
wsmoses merged 3 commits intomainfrom
nt
Oct 30, 2025
Merged

Error: improve no type error message#2719
wsmoses merged 3 commits intomainfrom
nt

Conversation

@wsmoses
Copy link
Member

@wsmoses wsmoses commented Oct 30, 2025

No description provided.

@github-actions
Copy link
Contributor

github-actions bot commented Oct 30, 2025

Your PR requires formatting changes to meet the project's style guidelines.
Please consider running Runic (git runic main) to apply these changes.

Click here to view the suggested changes.
diff --git a/src/errors.jl b/src/errors.jl
index 1e64c4b6..d5d9ad13 100644
--- a/src/errors.jl
+++ b/src/errors.jl
@@ -291,7 +291,7 @@ function InteractiveUtils.code_typed(ece::EnzymeRuntimeActivityError; interactiv
     end
 end
 
-struct EnzymeNoTypeError{MT,WT} <: EnzymeError
+struct EnzymeNoTypeError{MT, WT} <: EnzymeError
     msg::Cstring
     mi::MT
     world::WT
@@ -305,7 +305,7 @@ function Base.showerror(io::IO, ece::EnzymeNoTypeError)
     print(io, " Generally this shouldn't occur as Enzyme records type information from julia, but may be expected if you, for example copy untyped data.\n")
     print(io, " or alternatively emit very large sized registers that exceed the maximum size of Enzyme's type analysis. If it seems reasonable to differentiate\n")
     print(io, " this code, open an issue! If the cause of the error is too large of a register, you can request Enzyme increase the size (https://enzyme.mit.edu/julia/dev/api/#Enzyme.API.maxtypeoffset!-Tuple{Any})\n")
-    print(io, " or depth (https://enzyme.mit.edu/julia/dev/api/#Enzyme.API.maxtypedepth!-Tuple{Any}) of its type analysis.\n");
+    print(io, " or depth (https://enzyme.mit.edu/julia/dev/api/#Enzyme.API.maxtypedepth!-Tuple{Any}) of its type analysis.\n")
     print(io, " Alternatively, you can tell Enzyme to take its best guess from context with (https://enzyme.mit.edu/julia/dev/api/#Enzyme.API.looseTypeAnalysis!-Tuple{Any})\n")
     print(io, " All of these settings are global configurations that need to be set immeidately after loading Enzyme, before any differentiation occurs\n")
     print(io, " To toggle more information for debugging (needed for bug reports), set Enzyme.Compiler.VERBOSE_ERRORS[] = true (default false)\n")
@@ -313,7 +313,7 @@ function Base.showerror(io::IO, ece::EnzymeNoTypeError)
         msg = Base.unsafe_string(ece.msg)
         print(io, msg, '\n')
     end
-    if ece.mi !== nothing
+    return if ece.mi !== nothing
         print(io, " Failure within method: ", ece.mi, "\n")
         printstyled(io, "Hint"; bold = true, color = :cyan)
         printstyled(
@@ -324,7 +324,7 @@ function Base.showerror(io::IO, ece::EnzymeNoTypeError)
     end
 end
 
-function InteractiveUtils.code_typed(ece::EnzymeNoTypeError; interactive::Bool=false, kwargs...)
+function InteractiveUtils.code_typed(ece::EnzymeNoTypeError; interactive::Bool = false, kwargs...)
     mi = ece.mi
     if mi === nothing
         throw(AssertionError("code_typed(::EnzymeNoTypeError; interactive::Bool=false, kwargs...) not supported for error without mi"))
@@ -350,10 +350,10 @@ function InteractiveUtils.code_typed(ece::EnzymeNoTypeError; interactive::Bool=f
     interp = Enzyme.Compiler.Interpreter.EnzymeInterpreter(CT, nothing, world, mode, true)
 
     sig = mi.specTypes  # XXX: can we just use the method instance?
-    if interactive
+    return if interactive
         # call Cthulhu without introducing a dependency on Cthulhu
         mod = get(Base.loaded_modules, Cthulhu, nothing)
-        mod===nothing && error("Interactive code reflection requires Cthulhu; please install and load this package first.")
+        mod === nothing && error("Interactive code reflection requires Cthulhu; please install and load this package first.")
         descend_code_typed = getfield(mod, :descend_code_typed)
         descend_code_typed(sig; interp, kwargs...)
     else
@@ -562,7 +562,7 @@ function julia_error(
                 println(io, "within ", mi)
             end
         end
-	    
+
         mi = nothing
         world = nothing
 
@@ -1023,7 +1023,7 @@ end
             end
         end
         
-	    mi = nothing
+        mi = nothing
         world = nothing
 
         if isa(val, LLVM.Instruction)

@codecov
Copy link

codecov bot commented Oct 30, 2025

Codecov Report

❌ Patch coverage is 6.12245% with 46 lines in your changes missing coverage. Please review.
✅ Project coverage is 72.32%. Comparing base (a0e9679) to head (8d3afa1).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
src/errors.jl 6.12% 46 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2719      +/-   ##
==========================================
- Coverage   72.48%   72.32%   -0.17%     
==========================================
  Files          58       58              
  Lines       18635    18679      +44     
==========================================
+ Hits        13508    13510       +2     
- Misses       5127     5169      +42     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@wsmoses
Copy link
Member Author

wsmoses commented Oct 30, 2025

Closes #2715

@github-actions
Copy link
Contributor

github-actions bot commented Oct 30, 2025

Benchmark Results

main 8d3afa1... main / 8d3afa1...
basics/make_zero/namedtuple 0.0583 ± 0.006 μs 0.0568 ± 0.0049 μs 1.03 ± 0.14
basics/make_zero/struct 0.281 ± 0.021 μs 0.266 ± 0.016 μs 1.06 ± 0.1
basics/overhead 4.34 ± 0.01 ns 5.26 ± 0.01 ns 0.825 ± 0.0025
basics/remake_zero!/namedtuple 0.251 ± 0.022 μs 0.244 ± 0.021 μs 1.03 ± 0.13
basics/remake_zero!/struct 0.246 ± 0.019 μs 0.259 ± 0.024 μs 0.947 ± 0.12
fold_broadcast/multidim_sum_bcast/1D 10.9 ± 1.4 μs 10.9 ± 1.8 μs 0.999 ± 0.2
fold_broadcast/multidim_sum_bcast/2D 13.1 ± 0.51 μs 12.5 ± 0.61 μs 1.05 ± 0.066
time_to_load 1.36 ± 0.024 s 1.33 ± 0.0076 s 1.03 ± 0.019

Benchmark Plots

A plot of the benchmark results has been uploaded as an artifact at https://github.com/EnzymeAD/Enzyme.jl/actions/runs/18929686505/artifacts/4413592869.

@wsmoses wsmoses requested a review from vchuravy October 30, 2025 04:13
@wsmoses wsmoses merged commit 461bed8 into main Oct 30, 2025
43 of 49 checks passed
@wsmoses wsmoses deleted the nt branch October 30, 2025 06:24
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

Successfully merging this pull request may close these issues.

1 participant