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

@ct_enable incorrectly handles Vararg. #9

Open
MasonProtter opened this issue Sep 1, 2023 · 0 comments
Open

@ct_enable incorrectly handles Vararg. #9

MasonProtter opened this issue Sep 1, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@MasonProtter
Copy link
Contributor

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
@epatters epatters added the bug Something isn't working label Sep 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants