Unknown hang-up in v1.3.1

Julia v1.3.1 hangs when running the following call of pickvarnames(:(a + b)):

pickvarnames(ex::Symbol) = ex

function pickvarnames(ex::Expr)
    varnames = ()
    if ex.head == :call
        for arg in ex.args[2:end]
            varnames = (varnames..., pickvarnames(arg) )
        end
    end
    return varnames
end

julia> pickvarnames(:a)
:a

julia> pickvarnames(:(a + b) )
Killed: 9

why??? :dizzy_face:

I tried using Debugger.jl, calling @enter pickvarnames(:(a + b)) and there’s no problem stepping thru the whole function… what can I do??? thanks. :pray:

I can reproduce this with Julia 1.3, 1.2, and 0.7. It seems to work correctly in Julia 0.6. Probably worth opening an issue.

1 Like

I can reproduce on 1.4 and master.

Since all outputs are symbols, I would recommend returning a Vector{Symbol}, and for symbols too, eg

pickvarnames(ex::Symbol) = [ex]

function pickvarnames(ex::Expr)
    varnames = Symbol[]
    if ex.head == :call
        for arg in ex.args[2:end]
            append!(varnames, pickvarnames(arg))
        end
    end
    varnames
end
1 Like

… so… what could I do now? the hanging is really mysterious
how to investigate the cause so as to avoid the hang??? :cry:

It seems like an issue with the splatting that causes infinite loop somewhere in inference. This is a good candidate for an issue.

how to make sure that it is the exact problem?

julia> (()..., )
()

:point_up_2:it seems not the problem?

is the identication of the exact problem out of the reach of non-core guys (like me)? I mean, using tools like @code_xxx seems not showing the problem also…

I had tried the same things in global scope but had no problems too. In the mean time, when added @show before the said line in the function, interrupting the hanging process can show varnames within if statement. Maybe, I am mistaken about the source of problem but it hangs before showing varnames.

Open an issue and I assume that it will be dealt with.

done. thanks.