KernelAbstractions.jl icon indicating copy to clipboard operation
KernelAbstractions.jl copied to clipboard

Allow `return` or `return nothing` in kernels

Open eschnett opened this issue 1 year ago • 2 comments

I use JuliaFormatter to format my source code. This adds explicit return statements. This leads to

ERROR: LoadError: Return statement not permitted in a kernel function sum2_kernel!

even if the return statement is just return nothing.

At the same time, ending a kernel with an expression (which is equivalent to a return statement) is allowed.

Could this check be changed to allow only empty return or return nothing statements?

eschnett avatar Dec 13 '23 19:12 eschnett

At the same time, ending a kernel with an expression (which is equivalent to a return statement) is allowed.

KernelAbstractions will politly ignore those and insert a return nothing for you. But yes we could explicitly allow return or return nothing

vchuravy avatar Dec 18 '23 21:12 vchuravy

Closed by #446.

pxl-th avatar Jan 09 '24 16:01 pxl-th