AlgebraicJulia / AlgebraicJulia/CompTime.jl

`@ct_enable` incorrectly handles `Vararg`.

未关闭
#9 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
bug
主要语言
Julia
星标
73
派生
3
PR 合并指标
30 天内没有已合并 PR

描述

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
```

贡献指南

这个仓库没有索引到贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。