Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't precompile lines that use anonymous functions (fixes #26) #27

Merged
merged 1 commit into from
May 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/SnoopCompile.jl
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,10 @@ function extract_topmod(e)
return :unknown
end

const anonrex = r"##\d*#{1,2}\d*" # detect anonymous functions

function parse_call(line; subst=Vector{Pair{String, String}}(), blacklist=String[])
match(anonrex, line) === nothing || return false, line, :unknown
for (k, v) in subst
line = replace(line, k=>v)
end
Expand Down
8 changes: 8 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ if VERSION >= v"1.2.0-DEV.573"
""")
end

# issue #26
@snoopc "/tmp/anon.log" begin
map(x->x^2, [1,2,3])
end
data = SnoopCompile.read("/tmp/anon.log")
pc = SnoopCompile.parcel(reverse!(data[2]))
@test length(pc[:Base]) <= 1

#=
# Simple call
let str = "sum"
Expand Down