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

Fixing type piracy is becoming more urgent #512

Closed
KristofferC opened this issue Oct 24, 2023 · 6 comments · Fixed by #515
Closed

Fixing type piracy is becoming more urgent #512

KristofferC opened this issue Oct 24, 2023 · 6 comments · Fixed by #515

Comments

@KristofferC
Copy link

KristofferC commented Oct 24, 2023

The type piracy in

# TODO: fix piracy!
# * `Value` is not owned by Convex.jl
# * splatting creates zero-argument functions, which again are not owned by Convex.jl
hcat(args::AbstractExpr...) = HcatAtom(args...)
function hcat(args::AbstractExprOrValue...)
return HcatAtom(map(arg -> convert(AbstractExpr, arg), args)...)
end
hcat(args::Value...) = Base.cat(args..., dims = Val(2))

causes the package to now error on the 1.10 backport branch https://s3.amazonaws.com/julialang-reports/nanosoldier/pkgeval/by_hash/4e1759c_vs_0ba6ec2/EnsembleKalmanProcesses.primary.log

Failed to precompile Convex [f65535da-76fb-5f13-bab9-19810c17039a] to "/home/pkgeval/.julia/compiled/v1.10/Convex/jl_CmPZEd".
WARNING: Method definition hcat(Union{Number, AbstractArray{T, N} where N where T}...) in module Base at abstractarray.jl:1995 overwritten in module Convex at /home/pkgeval/.julia/packages/Convex/tSTAW/src/atoms/affine/stack.jl:120.
ERROR: LoadError: Method overwriting is not permitted during Module precompile.
Stacktrace:
 [1] top-level scope
   @ ~/.julia/packages/Convex/tSTAW/src/atoms/affine/stack.jl:120
@odow
Copy link
Member

odow commented Oct 24, 2023

Method overwriting is not permitted during Module precompile.

This seems like it is a breaking change to Julia then?

@KristofferC
Copy link
Author

Hm, I don't think so because this should have already printed that this type of method overwriting already is a fatal error, it just didn't hard error for it.

@odow
Copy link
Member

odow commented Oct 24, 2023

One issue with fixing this is that it would likely require a breaking change to Convex.jl (e.g., replacing Base.hcat with Convex.hcat), but https://github.com/jump-dev/Convex.jl#please-read-convexjl-needs-a-new-maintainer.

I guess we have no choice though.

@KristofferC
Copy link
Author

But isn't the solution here to instead of writing

 hcat(args::Value...) = Base.cat(args..., dims = Val(2)) 

to write something like

 hcat(arg::Value, args::Value...) = Base.cat((arg, args...)..., dims = Val(2)) 

or?

@odow
Copy link
Member

odow commented Oct 24, 2023

The issue is:

const Value = Union{Number,AbstractArray}

hcat(arg::Value, args::Value...) might fix that exact method, but it's still piracy.

@odow
Copy link
Member

odow commented Oct 26, 2023

@blegat asks: why is hcat(args::Value...) = Base.cat(args..., dims = Val(2)) even needed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants