Skip to content

Commit 893e796

Browse files
authored
Don't precompile lines that use anonymous functions (fixes #26) (#27)
1 parent 9245741 commit 893e796

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/SnoopCompile.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,10 @@ function extract_topmod(e)
171171
return :unknown
172172
end
173173

174+
const anonrex = r"##\d*#{1,2}\d*" # detect anonymous functions
175+
174176
function parse_call(line; subst=Vector{Pair{String, String}}(), blacklist=String[])
177+
match(anonrex, line) === nothing || return false, line, :unknown
175178
for (k, v) in subst
176179
line = replace(line, k=>v)
177180
end

test/runtests.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@ if VERSION >= v"1.2.0-DEV.573"
1515
""")
1616
end
1717

18+
# issue #26
19+
@snoopc "/tmp/anon.log" begin
20+
map(x->x^2, [1,2,3])
21+
end
22+
data = SnoopCompile.read("/tmp/anon.log")
23+
pc = SnoopCompile.parcel(reverse!(data[2]))
24+
@test length(pc[:Base]) <= 1
25+
1826
#=
1927
# Simple call
2028
let str = "sum"

0 commit comments

Comments
 (0)