Skip to content

Vararg{Any} is not behaving the same as Vararg{Any, N} where N #33987

@schlichtanders

Description

@schlichtanders

dear out there,

I just stumbled upon the maybe most weird julia bug I experienced so far

f1(args::(Vararg{Any, N} where N); kwargs...) = (args, kwargs)
f2(args::(Vararg{Any, N} where N)) = (args, 1)
f3(args::(Vararg{Any}); kwargs...) = (args, kwargs)

@show f1(1,2,3) f2(1,2,3) f3(1,2,3)

will print

f1(1, 2, 3) = (((1, 2, 3),), Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}())
f2(1, 2, 3) = ((1, 2, 3), 1)
f3(1, 2, 3) = ((1, 2, 3), Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}())

The core difference is that for f1 the args get packed into an EXTRA level of Tuple...

Super weird, especially because

  • Vararg{Any} === Vararg{Any, N} where N gives true

version: this run on julia 1.2.0

Metadata

Metadata

Assignees

Labels

bugIndicates an unexpected problem or unintended behaviorkeyword argumentsf(x; keyword=arguments)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions