Julia is crashing when I try to define a Base.length
method on a const
type alias.
julia> import Base: length
julia> const A{N} = NTuple{N, Int64}
Tuple{Vararg{Int64, N}} where N
julia> length(a::A) = prod(a)
After this, julia does not throw any errors but crashes when I try to execute any other code. Is this something wrong with my code or is it a bug?
I managed to get the stderr
output during the crash:
fatal: error thrown and no exception handler available.
BoundsError(a=(), i=1)
ijl_bounds_error_int at /cache/build/builder-amdci4-0/julialang/julia-release-1-dot-10/src/rtutils.c:187
ijl_get_nth_field at /cache/build/builder-amdci4-0/julialang/julia-release-1-dot-10/src/datatype.c:1569
ijl_get_nth_field_checked at /cache/build/builder-amdci4-0/julialang/julia-release-1-dot-10/src/datatype.c:1614
getindex at ./tuple.jl:31 [inlined]
iterate at ./tuple.jl:72 [inlined]
iterate at ./tuple.jl:72
unknown function (ip: 0x7c96086e7c75)
iterate at ./iterators.jl:298
isempty at ./essentials.jl:957
schedule at ./task.jl:849
unknown function (ip: 0x7c96086e9e60)
notify at ./condition.jl:154 [inlined]
#notify#646 at ./condition.jl:148 [inlined]
notify at ./condition.jl:148 [inlined]
notify at ./condition.jl:148 [inlined]
task_done_hook at ./task.jl:658
unknown function (ip: 0x7c96086e9e05)
_jl_invoke at /cache/build/builder-amdci4-0/julialang/julia-release-1-dot-10/src/gf.c:2895 [inlined]
ijl_apply_generic at /cache/build/builder-amdci4-0/julialang/julia-release-1-dot-10/src/gf.c:3077
jl_apply at /cache/build/builder-amdci4-0/julialang/julia-release-1-dot-10/src/julia.h:1982 [inlined]
jl_finish_task at /cache/build/builder-amdci4-0/julialang/julia-release-1-dot-10/src/task.c:320
start_task at /cache/build/builder-amdci4-0/julialang/julia-release-1-dot-10/src/task.c:1249
e[2 qschedule: Task not runnable
atexit hook threw an error: ErrorException("schedule: Task not runnable")
error at ./error.jl:35
#schedule#673 at ./task.jl:851
schedule at ./task.jl:849 [inlined]
uv_writecb_task at ./stream.jl:1166
unknown function (ip: 0x7c96086ec31c)
uv__write_callbacks at /workspace/srcdir/libuv/src/unix/stream.c:959
uv__stream_io at /workspace/srcdir/libuv/src/unix/stream.c:1294
uv__run_pending at /workspace/srcdir/libuv/src/unix/core.c:804
uv_run at /workspace/srcdir/libuv/src/unix/core.c:392
ijl_task_get_next at /cache/build/builder-amdci4-0/julialang/julia-release-1-dot-10/src/partr.c:478
poptask at ./task.jl:985
wait at ./task.jl:994
uv_write at ./stream.jl:1048
unsafe_write at ./stream.jl:1120
write at ./strings/io.jl:248 [inlined]
print at ./strings/io.jl:250
unknown function (ip: 0x7c96086ecce9)
_jl_invoke at /cache/build/builder-amdci4-0/julialang/julia-release-1-dot-10/src/gf.c:2895 [inlined]
ijl_apply_generic at /cache/build/builder-amdci4-0/julialang/julia-release-1-dot-10/src/gf.c:3077
showerror at ./errorshow.jl:151
unknown function (ip: 0x7c96086ed179)
_jl_invoke at /cache/build/builder-amdci4-0/julialang/julia-release-1-dot-10/src/gf.c:2895 [inlined]
ijl_apply_generic at /cache/build/builder-amdci4-0/julialang/julia-release-1-dot-10/src/gf.c:3077
_atexit at ./initdefs.jl:431
unknown function (ip: 0x7c96086ea827)
_jl_invoke at /cache/build/builder-amdci4-0/julialang/julia-release-1-dot-10/src/gf.c:2895 [inlined]
ijl_apply_generic at /cache/build/builder-amdci4-0/julialang/julia-release-1-dot-10/src/gf.c:3077
jl_apply at /cache/build/builder-amdci4-0/julialang/julia-release-1-dot-10/src/julia.h:1982 [inlined]
ijl_atexit_hook at /cache/build/builder-amdci4-0/julialang/julia-release-1-dot-10/src/init.c:280
ijl_exit at /cache/build/builder-amdci4-0/julialang/julia-release-1-dot-10/src/init.c:207
ijl_no_exc_handler at /cache/build/builder-amdci4-0/julialang/julia-release-1-dot-10/src/task.c:699
jl_finish_task at /cache/build/builder-amdci4-0/julialang/julia-release-1-dot-10/src/task.c:323
start_task at /cache/build/builder-amdci4-0/julialang/julia-release-1-dot-10/src/task.c:1249
error in running finalizer: BoundsError(a=(), i=1)
ijl_bounds_error_int at /cache/build/builder-amdci4-0/julialang/julia-release-1-dot-10/src/rtutils.c:187
ijl_get_nth_field at /cache/build/builder-amdci4-0/julialang/julia-release-1-dot-10/src/datatype.c:1569
ijl_get_nth_field_checked at /cache/build/builder-amdci4-0/julialang/julia-release-1-dot-10/src/datatype.c:1614
getindex at ./tuple.jl:31 [inlined]
iterate at ./tuple.jl:72 [inlined]
iterate at ./tuple.jl:72
unknown function (ip: 0x7c96086e7c75)
iterate at ./iterators.jl:298
isempty at ./essentials.jl:957
schedule at ./task.jl:849
notify at ./condition.jl:154 [inlined]
#notify#646 at ./condition.jl:148 [inlined]
notify at ./condition.jl:148 [inlined]
uvfinalize at ./asyncevent.jl:205
unknown function (ip: 0x7c96086ed7c5)
_jl_invoke at /cache/build/builder-amdci4-0/julialang/julia-release-1-dot-10/src/gf.c:2895 [inlined]
ijl_apply_generic at /cache/build/builder-amdci4-0/julialang/julia-release-1-dot-10/src/gf.c:3077
run_finalizer at /cache/build/builder-amdci4-0/julialang/julia-release-1-dot-10/src/gc.c:318
jl_gc_run_finalizers_in_list at /cache/build/builder-amdci4-0/julialang/julia-release-1-dot-10/src/gc.c:408
run_finalizers at /cache/build/builder-amdci4-0/julialang/julia-release-1-dot-10/src/gc.c:454
ijl_atexit_hook at /cache/build/builder-amdci4-0/julialang/julia-release-1-dot-10/src/init.c:299
ijl_exit at /cache/build/builder-amdci4-0/julialang/julia-release-1-dot-10/src/init.c:207
ijl_no_exc_handler at /cache/build/builder-amdci4-0/julialang/julia-release-1-dot-10/src/task.c:699
jl_finish_task at /cache/build/builder-amdci4-0/julialang/julia-release-1-dot-10/src/task.c:323
start_task at /cache/build/builder-amdci4-0/julialang/julia-release-1-dot-10/src/task.c:1249
Yet a similar definition of the method for intersect
works as intended
julia> import Base: intersect
julia> const A{N} = NTuple{N, Int64}
Tuple{Vararg{Int64, N}} where N
julia> intersect(a::A{N}, as::A{N}...) where {N} = prod.([a, as...])
intersect (generic function with 43 methods)
julia> intersect((5,4,5,4), (4,5,3,3))
2-element Vector{Int64}:
400
180
version: julia version 1.10.4