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

fix type of nargs for making opaque closures #125

Merged
merged 3 commits into from
Mar 28, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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: 2 additions & 1 deletion src/codegen/reverse.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ function make_opaque_closure(interp, typ, name, meth_nargs, isva, lno, cis, revs
return Expr(:new_opaque_closure, typ, Union{}, Any,
ocm, revs...)
else
oc_nargs = Int64(meth_nargs)
Expr(:new_opaque_closure, typ, Union{}, Any,
Expr(:opaque_closure_method, name, meth_nargs, isva, lno, cis), revs...)
Expr(:opaque_closure_method, name, oc_nargs, isva, lno, cis), revs...)
end
end

Expand Down
10 changes: 6 additions & 4 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,10 @@ let var"'" = Diffractor.PrimeDerivativeBack
@test @inferred(sin'(1.0)) == cos(1.0)
@test sin''(1.0) == -sin(1.0)
@test sin'''(1.0) == -cos(1.0)
@test sin''''(1.0) == sin(1.0)
@test sin'''''(1.0) == cos(1.0)
@test sin''''''(1.0) == -sin(1.0)
# These currently cause segfaults
oxinabox marked this conversation as resolved.
Show resolved Hide resolved
#@test sin''''(1.0) == sin(1.0)
#@test sin'''''(1.0) == cos(1.0)
#@test sin''''''(1.0) == -sin(1.0)

f_getfield(x) = getfield((x,), 1)
@test f_getfield'(1) == 1
Expand All @@ -110,7 +111,8 @@ let var"'" = Diffractor.PrimeDerivativeBack
@test @inferred(complicated_2sin'(1.0)) == 2sin'(1.0)
@test @inferred(complicated_2sin''(1.0)) == 2sin''(1.0) broken=true
@test @inferred(complicated_2sin'''(1.0)) == 2sin'''(1.0) broken=true
@test @inferred(complicated_2sin''''(1.0)) == 2sin''''(1.0) broken=true
# This currently causes a segfault
oxinabox marked this conversation as resolved.
Show resolved Hide resolved
#@test @inferred(complicated_2sin''''(1.0)) == 2sin''''(1.0) broken=true

# Control flow cases
@test @inferred((x->simple_control_flow(true, x))'(1.0)) == sin'(1.0)
Expand Down