From 96c351e7ac9b8b3f2457ce1ce00051f609aada2e Mon Sep 17 00:00:00 2001 From: Tim Besard Date: Tue, 12 Sep 2023 10:05:38 +0200 Subject: [PATCH] Don't disallow Bottom returns. (#510) Although we inferred some kind of error, it's likely that deferring validation will yield better error messages. --- src/validation.jl | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/validation.jl b/src/validation.jl index d3480b55..f6e54b81 100644 --- a/src/validation.jl +++ b/src/validation.jl @@ -32,11 +32,9 @@ function check_method(@nospecialize(job::CompilerJob)) if job.config.kernel rt = typeinf_type(job.source; interp=get_interpreter(job)) - if rt != Nothing + if rt != Nothing && rt != Union{} throw(KernelError(job, "kernel returns a value of type `$rt`", - """Make sure your kernel function ends in `return`, `return nothing` or `nothing`. - If the returned value is of type `Union{}`, your Julia code probably throws an exception. - Inspect the code with `@device_code_warntype` for more details.""")) + """Make sure your kernel function ends in `return`, `return nothing` or `nothing`.""")) end end