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

MWE for failing test for errorshow.jl or "Varargs, the undead of the Julia Type system" #130

Closed
macd opened this issue Mar 12, 2019 · 0 comments

Comments

@macd
Copy link
Contributor

macd commented Mar 12, 2019

It turns out that the failure in errorshow.jl has to do with handling
Varargs. Due to JuliaLang/julia#30995, there is
a check in prepare_call in construct.jl that will punt if any of the args
is a Vararg. But that is the problem, there is not an easy way to test the
different forms of Vararg that come through.

The test is currently elseif any(x->isa(x, Type) && x <: Vararg, allargs)
however, one form of that comes through is x = Vararg{AbstractString,N} where {N}
and isa(x, Type) tests true but x <: Vararg is false. typeof(x) returns
a UnionALL. Another arg that comes through is Vararg{AbstractString,N}, that
is, there is no where clause?! I don't understand how that is possible.

I could not construct a test to get these two, and only these two, using type checking.
For the purposes of testing, I used the brute force approach of
elseif any(x->isa(x, Type) && occursin("Vararg", string(x)), allargs) The unit
tests for JuliaInterpreter run OK with this and the following MWE passes, but there should
be a better way to do that, so I did not prepare a PR.

using JuliaInterpreter
include("utils.jl")

module m
    method_c1(x::Float64, s::AbstractString...) = true
    buf = IOBuffer()
    me = Base.MethodError(method_c1,(1, 1, ""))
end

ex = quote
    Base.show_method_candidates(buf, me)
end

# TypeError: in Type, in parameter, expected Type, got Vararg{AbstractString,N} where N

frame = JuliaInterpreter.prepare_thunk(m, ex)
JuliaInterpreter.finish_and_return!(frame)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant