Weird docstrings error

MWE:

abstract type SpinCategory end

struct SpinAware <: SpinCategory end

""" Looks at axes to figure out the spin category

- no spin-axis -> SpinDegenerate
- fastest changing dimension -> ColinearSpinFirst
- `n`th dim -> ColinearSpin{n}

"""
(::Type{SpinCategory})(array::Array) = SpinCategory(axes(array))

I have no clue what our why this is happening. Any ideas?

The error is

ERROR: LoadError: BoundsError: attempt to access 1-element Array{Any,1} at index [2]

This reduced test case also exhibits the error:

"Looks at axes to figure out the spin category."
(::Type{Int})() = 1

The error appears to be coming from from the .args[2] indexing on the return astname line in this function in Docs.jl:

function astname(x::Expr, ismacro::Bool)
    if isexpr(x, :.)
        ismacro ? macroname(x) : x
    # Call overloading, e.g. `(a::A)(b) = b` or `function (a::A)(b) b end` should document `A(b)`
    elseif (isexpr(x, :function) || isexpr(x, :(=))) && isexpr(x.args[1], :call) && isexpr(x.args[1].args[1], :(::))
        return astname(x.args[1].args[1].args[2], ismacro)
    else
        n = isexpr(x, (:module, :struct)) ? 2 : 1
        astname(x.args[n], ismacro)
    end
end
1 Like

I thought I recognized that code… https://github.com/JuliaLang/julia/pull/25626. Looks like it wasnt 100% correct, heh.

1 Like
2 Likes