diff --git a/Project.toml b/Project.toml index 76eba6a..8e5bd89 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "ExprTools" uuid = "e2ba6199-217a-4e67-a87a-7c52f15ade04" -version = "0.1.11" +version = "0.1.12" [compat] julia = "1" diff --git a/docs/make.jl b/docs/make.jl index 7c99b81..583ac1f 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -6,6 +6,7 @@ makedocs(; authors="Curtis Vogt ", repo="https://github.com/JuliaTesting/ExprTools.jl/blob/{commit}{path}#L{line}", sitename="ExprTools.jl", + checkdocs=:exports, format=Documenter.HTML(; prettyurls=get(ENV, "CI", "false") == "true", canonical="https://JuliaTesting.github.io/ExprTools.jl", diff --git a/docs/src/api.md b/docs/src/api.md index f005fd7..24bb213 100644 --- a/docs/src/api.md +++ b/docs/src/api.md @@ -11,4 +11,6 @@ CurrentModule = ExprTools splitdef combinedef signature +parameters +args_tuple_expr ``` diff --git a/docs/src/index.md b/docs/src/index.md index e64bde2..bd93e5e 100644 --- a/docs/src/index.md +++ b/docs/src/index.md @@ -20,12 +20,13 @@ julia> ex = :( end ) :(function Base.f(x::T, y::T) where T + #= none:2 =# #= none:3 =# x + y end) julia> def = splitdef(ex) -Dict{Symbol,Any} with 5 entries: +Dict{Symbol, Any} with 5 entries: :args => Any[:(x::T), :(y::T)] :body => quote… :name => :(Base.f) @@ -45,10 +46,11 @@ julia> eval(g_expr) g (generic function with 1 method) julia> g_method = first(methods(g)) -g(x::T, y::T) where T in Main +g(x::T, y::T) where T + @ Main none:0 julia> signature(g_method) -Dict{Symbol,Any} with 3 entries: +Dict{Symbol, Any} with 3 entries: :name => :g :args => Expr[:(x::T), :(y::T)] :whereparams => Any[:T] diff --git a/src/function.jl b/src/function.jl index ce50eff..7930e6c 100644 --- a/src/function.jl +++ b/src/function.jl @@ -84,7 +84,14 @@ function splitdef(ex::Expr; throw::Bool=true) if length(ex.args) >= i if ex.args[i] isa Expr && ex.args[i].head === :parameters - def[:kwargs] = ex.args[i].args + def[:kwargs] = Any[] + for arg in ex.args[i].args + if arg isa Expr && arg.head === :parameters + return invalid_def("more than one semicolon in argument list") + else + push!(def[:kwargs], arg) + end + end if length(ex.args) > i def[:args] = ex.args[(i + 1):end] diff --git a/test/function.jl b/test/function.jl index df85d62..5225e6b 100644 --- a/test/function.jl +++ b/test/function.jl @@ -875,8 +875,7 @@ function_form(short::Bool) = string(short ? "short" : "long", "-form") @test_broken splitdef(:(a::Number::Int -> a); throws=false) === nothing # Invalid argument block expression - ex = :((x; y; z) -> 0) # Note: inlining this strips LineNumberNodes from the block - @test any(arg -> arg isa LineNumberNode, ex.args[1].args) + ex = :((x; y; z) -> 0) @test_splitdef_invalid ex @test_splitdef_invalid Expr(:->, Expr(:block, :x, :y, :z), Expr(:block, 0))