Skip to content

Variadic generic default argument does not work for single element cases #81741

Open
@hamishknight

Description

@hamishknight

This works:

func foo<each T>(xs: (repeat each T) = (0, 0)) {}

This doesn't:

func foo<each T>(xs: (repeat each T) = 0) {}
// error: Default argument value of type 'Int' cannot be converted to type '(repeat each T)'
Swift version 6.2-dev (LLVM 872428812ba43af, Swift 9ed8b664fd017bc)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfdefault argumentsFeature: default arguments for value parametersgenericsFeature: generic declarations and typesparameter packsFeature → generics: Parameter packstype checkerArea → compiler: Semantic analysis

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions