Skip to content

Vararg can follow optional arg if declared with ellipsis but not with Vararg #56221

Open
@danielwe

Description

@danielwe
julia> f(x=1, args...) = (x, args...)  # works as expected
f (generic function with 2 methods)

julia> g(x=1, args::Vararg) = (x, args...)
ERROR: syntax: optional positional arguments must occur at end around REPL[17]:1
Stacktrace:
 [1] top-level scope
   @ REPL[17]:1

It would be great if the latter form worked, as Vararg allows more flexible type constraints and specializations than ..., including working around avoided specialization as per https://docs.julialang.org/en/v1/manual/performance-tips/#Be-aware-of-when-Julia-avoids-specializing

Metadata

Metadata

Assignees

No one assigned

    Labels

    compiler:loweringSyntax lowering (compiler front end, 2nd stage)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions