Skip to content

Commit ab95d63

Browse files
committed
Fix opaque_closure for v1.12
1 parent bfd8b2f commit ab95d63

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/utils.jl

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,21 +189,25 @@ function opaque_closure(
189189
# This implementation is copied over directly from `Core.OpaqueClosure`.
190190
ir = CC.copy(ir)
191191
@static if VERSION >= v"1.12-"
192+
ir.debuginfo.def === nothing &&
193+
(ir.debuginfo.def = :var"generated IR for OpaqueClosure")
192194
# On v1.12 OpaqueClosure expects the first arg to be the environment.
193195
ir.argtypes[1] = typeof(env)
194196
end
195-
nargs = length(ir.argtypes) - 1
197+
nargtypes = length(ir.argtypes)
198+
nargs = nargtypes - 1
196199
@static if VERSION >= v"1.12-"
197200
sig = CC.compute_oc_signature(ir, nargs, isva)
198201
else
199202
sig = Base.Experimental.compute_oc_signature(ir, nargs, isva)
200203
end
201204
src = ccall(:jl_new_code_info_uninit, Ref{CC.CodeInfo}, ())
202-
src.slotnames = fill(:none, nargs + 1)
203-
src.slotflags = fill(zero(UInt8), length(ir.argtypes))
205+
src.slotnames = fill(:none, nargtypes)
206+
src.slotflags = fill(zero(UInt8), nargtypes)
204207
src.slottypes = copy(ir.argtypes)
205208
src.rettype = ret_type
206209
@static if VERSION >= v"1.12-"
210+
src.isva = isva
207211
src.nargs = UInt(nargs + 1)
208212
end
209213
src = CC.ir_to_codeinf!(src, ir)

0 commit comments

Comments
 (0)