Skip to content

Commit

Permalink
fix cfunction escaping bug (#566)
Browse files Browse the repository at this point in the history
  • Loading branch information
stevengj authored and ararslan committed Jun 6, 2018
1 parent e991ead commit 59a67a4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Compat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1914,7 +1914,7 @@ end
# 0.7.0-DEV.4762
@static if !isdefined(Base, Symbol("@cfunction"))
macro cfunction(f, rt, tup)
:(Base.cfunction($f, $rt, Tuple{$tup...}))
:(Base.cfunction($(esc(f)), $(esc(rt)), Tuple{$(esc(tup))...}))
end
export @cfunction
end
Expand Down
8 changes: 8 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1749,6 +1749,14 @@ let ptr = @cfunction(+, Int, (Int, Int))
@test ptr != C_NULL
@test ccall(ptr, Int, (Int, Int), 2, 3) == 5
end
# issue #565
issue565(x) = x + 1
const Issue565 = Int
let bar() = @cfunction(issue565, Issue565, (Issue565,)), ptr = bar()
@test ptr isa Ptr{Cvoid}
@test ptr != C_NULL
@test ccall(ptr, Int, (Int,), 2) === 3
end

# 0.7.0-DEV.5278
@test something(nothing, 1) === 1
Expand Down

0 comments on commit 59a67a4

Please sign in to comment.