Skip to content

Commit c55fbd0

Browse files
authored
Merge pull request #9 from JuliaDebug/teh/anon
Ensure that anonymous functions get defined
2 parents 877f033 + a79cd22 commit c55fbd0

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/LoweredCodeUtils.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,12 @@ function methoddef!(@nospecialize(recurse), signatures, frame::Frame, @nospecial
348348
meth = whichtt(sigt)
349349
if isa(meth, Method)
350350
push!(signatures, meth.sig)
351+
elseif stmt.args[1] == false
352+
# If it's anonymous and not defined, define it
353+
pc = step_expr!(recurse, frame, stmt, true)
354+
meth = whichtt(sigt)
355+
isa(meth, Method) && push!(signatures, meth.sig)
356+
return pc, pc3
351357
else
352358
# guard against busted lookup, e.g., https://github.com/JuliaLang/julia/issues/31112
353359
code = framecode.src

test/runtests.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,4 +191,11 @@ end
191191
end
192192
pc, pc3 = methoddef!(signatures, frame; define=false) # this tests that the return isn't `nothing`
193193
@test length(signatures) == 2 # both the GeneratedFunctionStub and the main method
194+
195+
# With anonymous functions in signatures
196+
ex = :(const BitIntegerType = Union{map(T->Type{T}, Base.BitInteger_types)...})
197+
frame = JuliaInterpreter.prepare_thunk(Lowering, ex)
198+
empty!(signatures)
199+
methoddefs!(signatures, frame; define=false)
200+
@test !isempty(signatures)
194201
end

0 commit comments

Comments
 (0)