-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Function erroring inside @testset
but not outside
#23878
Comments
It looks like the linearizer in lowering fails to handle the first argument to ccall / foreigncall correctly. |
Bump :-) |
Bump 2 :-) Note also this is a regression, it used to work in Julia 0.6 and I bisected to #23698, as indicated in the first message. Perhaps should be labeled as such? |
Bump 3 :-) Is there any chance to have this fixed for Julia 0.7/1.0? |
Seems fixed now? |
It wasn't when I wrote the last message. Will check again next week. |
Ok, I've checked now, it works, thanks. Side question: why this? julia> begin
f(x) = x*x
ptr = @cfunction(f, Cdouble, (Cdouble,))
end
ERROR: UndefVarError: f not defined I guess there is a scope issue, but I can't see how to fix it. It used to work with Julia 0.6. Looking for "begin" and "scope" in the release notes for Julia 0.7 I don't see anything related. |
Use |
Already tried that, but it wasn't clear to me how to use a begin
f(x) = x*x
ptr = @cfunction($f, Cdouble, (Cdouble,))
g(x) = ccall(ptr, Cdouble, (Cdouble,), x)
g(1.0)
end
ERROR: TypeError: in g, in ccall: first argument not a pointer or valid constant expression, expected Ptr, got Base.CFunction
So should I convert the |
I guess Edit: continued on discourse: https://discourse.julialang.org/t/using-a-base-cfunction-in-ccall/13621 |
Let's continue this on discourse. |
On Julia master, this works:
but if this is wrapped in a
@testset
, it errors badly:With git-bisect I found this started to happen with PR #23698.
First reported on Discourse: https://discourse.julialang.org/t/function-erroring-inside-testset-but-not-outside/6064
The text was updated successfully, but these errors were encountered: