diff --git a/src/ast/printing.jl b/src/ast/printing.jl index eecc880..c0da0c7 100644 --- a/src/ast/printing.jl +++ b/src/ast/printing.jl @@ -1,5 +1,14 @@ tab(n::Int) = " "^n -ignore_type(type) = type in [Any, String] || type <: AbstractString + +function is_vararg(T) + @static if VERSION < v"1.7" + T <: Vararg + else + typeof(T) == Core.TypeofVararg + end +end + +ignore_type(type) = !is_vararg(type) && (type in [Any, String] || type <: AbstractString) function has_args(cmd::LeafCommand) !isempty(cmd.args) || !isnothing(cmd.vararg) diff --git a/test/runtests.jl b/test/runtests.jl index 530e6d2..c387a1f 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -23,6 +23,7 @@ end include("frontend/cast.jl") include("frontend/markdown.jl") include("long_print.jl") + include("vararg.jl") end @testset "codegen" begin diff --git a/test/vararg.jl b/test/vararg.jl new file mode 100644 index 0000000..6e6c249 --- /dev/null +++ b/test/vararg.jl @@ -0,0 +1,2 @@ +using Comonicon +@main foo(xs::Vararg{String}) = foreach(println, xs)