You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In #72 we ended up appending the TaskArgByValue and TaskArgByReference instances to a Vector{Any} even when TaskArgByValue <: TaskArg and TaskArgByReference <: TaskArg. This is due to how CxxWrap handles convert:
julia> task_arg
ray_core_worker_julia_jll.TaskArgByValueAllocated(Ptr{Nothing} @0x0000600000e24be0)
julia> x = ray_jll.TaskArg[]
ray_core_worker_julia_jll.TaskArg[]
julia>push!(x, task_arg)
ERROR: MethodError: Cannot `convert` an object of type CxxRef{ray_core_worker_julia_jll.TaskArg} to an object of type ray_core_worker_julia_jll.TaskArg
Closest candidates are:convert(::Type{ray_core_worker_julia_jll.TaskArg}, ::ray_core_worker_julia_jll.TaskArgDereferenced)
@ ray_core_worker_julia_jll ~/.julia/packages/CxxWrap/aXNBY/src/CxxWrap.jl:687convert(::Type{ray_core_worker_julia_jll.TaskArg}, ::ray_core_worker_julia_jll.TaskArgAllocated)
@ ray_core_worker_julia_jll ~/.julia/packages/CxxWrap/aXNBY/src/CxxWrap.jl:686convert(::Type{ray_core_worker_julia_jll.TaskArg}, ::T) where T<:ray_core_worker_julia_jll.TaskArg
@ ray_core_worker_julia_jll ~/.julia/packages/CxxWrap/aXNBY/src/CxxWrap.jl:682...
Stacktrace:
[1] setindex!(A::Vector{ray_core_worker_julia_jll.TaskArg}, x::CxxRef{ray_core_worker_julia_jll.TaskArg}, i1::Int64)
@ Base ./array.jl:969
[2] push!(a::Vector{ray_core_worker_julia_jll.TaskArg}, item::ray_core_worker_julia_jll.TaskArgByValueAllocated)
@ Base ./array.jl:1062
[3] top-level scope
@ REPL[15]:1
I believe this is due to how C++ handles class inheritance. If you have a std::vector<TaskArg> then all instances of that class are just TaskArg. We can see this in Julia by using a StdVector:
I think what should probably happen is that when using a Julia Vector the types should behave more like how Julia typicaly does where a Vector{TaskArg} contains the concrete subtypes of TaskArgByValue and TaskArgByReference and when using a StdVector the types are automatically casted. Doing this would require CxxWrap to have it's own say cconvert function which works differently from the default convert (note: the default push! calls convert).
The text was updated successfully, but these errors were encountered:
In #72 we ended up appending the
TaskArgByValue
andTaskArgByReference
instances to aVector{Any}
even whenTaskArgByValue <: TaskArg
andTaskArgByReference <: TaskArg
. This is due to how CxxWrap handlesconvert
:I believe this is due to how C++ handles class inheritance. If you have a
std::vector<TaskArg>
then all instances of that class are justTaskArg
. We can see this in Julia by using aStdVector
:I think what should probably happen is that when using a Julia
Vector
the types should behave more like how Julia typicaly does where aVector{TaskArg}
contains the concrete subtypes ofTaskArgByValue
andTaskArgByReference
and when using aStdVector
the types are automatically casted. Doing this would require CxxWrap to have it's own saycconvert
function which works differently from the defaultconvert
(note: the defaultpush!
callsconvert
).The text was updated successfully, but these errors were encountered: