Skip to content

@ct_enable incorrectly handles Vararg.  #9

@MasonProtter

Description

@MasonProtter

Here's a MWE:

julia> @ct_enable function f(x::Vararg{Any, N}) where {N}
           N
       end
ERROR: TypeError: in TypeVar, in upper bound, expected Type, got Vararg{Any, N}
Stacktrace:
 [1] TypeVar(n::Symbol, ub::Any)
   @ Core ./boot.jl:254
 [2] top-level scope
   @ REPL[24]:1

and here's what's going wrong:

julia> @macroexpand1 @ct_enable function f(x::Vararg{Any, N}) where {N}
           N
       end
quote
    #= REPL[25]:1 =#
    function f(x::Vararg{Any, N}; ) where N
        (CompTime.comptime)(f, x)
    end
    #= REPL[25]:1 =#
    function CompTime.generate_code(::(typeof)(f), ::(Type){<:Vararg{Any, N}}; ) where N # <-------- This is bad
        $(Expr(:copyast, :($(QuoteNode(quote
    #= REPL[25]:1 =#
    #= REPL[25]:2 =#
    N
end)))))
    end
    #= REPL[25]:1 =#
    function CompTime.comptime(::(typeof)(f), x::Vararg{Any, N}; ) where N
        #= /home/mason/.julia/packages/CompTime/Ppb3B/src/CompTime.jl:137 =#
        if $(Expr(:generated))
            #= /home/mason/.julia/packages/CompTime/Ppb3B/src/CompTime.jl:138 =#
            (CompTime.generate_code)(f, Vararg{Any, N})
        else
            #= /home/mason/.julia/packages/CompTime/Ppb3B/src/CompTime.jl:140 =#
            $(Expr(:meta, :generated_only))
        end
    end
    #= REPL[25]:1 =#
    function CompTime.runtime(::(typeof)(f), x::Vararg{Any, N}; ) where N
        #= REPL[25]:1 =#
        #= REPL[25]:2 =#
        N
    end
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions