Skip to content

Commit fb30afa

Browse files
authored
Restrict recursive evaluations to gensymmed methods (#15)
Changes to lowering over time mean that some Julia versions might have a non-gensymmed :method as the first entry
1 parent 08eb9a8 commit fb30afa

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/LoweredCodeUtils.jl

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -403,10 +403,9 @@ function methoddef!(@nospecialize(recurse), signatures, frame::Frame, @nospecial
403403
pc0 = pc
404404
idx1 = findall(ismethod1, frame.framecode.src.code)
405405
idx1 = idx1[idx1 .>= pc]
406+
hashhash = map(idx->startswith(String(pc_expr(frame, idx).args[1]), '#'), idx1)
407+
idx1 = idx1[hashhash]
406408
i = length(idx1)
407-
while i > 1 && !startswith(String(pc_expr(frame, idx1[i]).args[1]), '#')
408-
i -= 1
409-
end
410409
while i > 1
411410
frame.pc = idx1[i]
412411
methoddef!(recurse, [], frame, frame.pc; define=define)
@@ -422,7 +421,7 @@ function methoddef!(@nospecialize(recurse), signatures, frame::Frame, @nospecial
422421
stmt = pc_expr(frame, pc)
423422
while !isexpr(stmt, :method, 3)
424423
pc = next_or_nothing(frame, pc) # this should not check define, we've probably already done this once
425-
pc === nothing && return pc # this was just `function foo end`, signal "no def"
424+
pc === nothing && return nothing # this was just `function foo end`, signal "no def"
426425
stmt = pc_expr(frame, pc)
427426
end
428427
pc3 = pc

0 commit comments

Comments
 (0)