AlgebraicJulia / AlgebraicJulia/CompTime.jl

`@ct_enable` incorrectly handles `Vararg`.

Open
#9 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Julia
Stars
73
Forks
3
PR merge metrics
No merged PRs in 30d

Description

Here's a MWE:
```julia
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
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
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.