Skip to content

Using packs in closure: cannot fully abstract a value of variadic function type. #69412

Open
@CrystDragon

Description

@CrystDragon

Description
I want to implement a variadic version of the currying function.

func curried<First, each T, Result>(
  _ originalFunc: @escaping (First, repeat each T) -> Result
) -> (First) -> (repeat each T) -> Result {
  return { (first: First) in
    return { (remanings: repeat each T) -> Result in
      return originalFunc(first, repeat each remanings)
    }
  }
}

The error message is:

error: cannot fully abstract a value of variadic function type '(repeat each T) -> Result' because different contexts will not be able to reliably agree on a calling convention; try wrapping it in a struct
error: cannot fully abstract a value of variadic function type '(repeat each T) -> Result' because different contexts will not be able to reliably agree on a calling convention; try wrapping it in a struct

I have no idea what it means by " try wrapping it in a struct", it seems unrelated.

Environment

  • 1.87.1 Apple Swift version 5.9 (swiftlang-5.9.0.128.108 clang-1500.0.40.1)
  • Xcode 15.0 (15A240d)

Metadata

Metadata

Assignees

No one assigned

    Labels

    SILGenArea → compiler: The SIL generation stagebugA deviation from expected or documented behavior. Also: expected but undesirable behavior.closuresFeature: closurescompilerThe Swift compiler itselfexpressionsFeature: expressionsgenericsFeature: generic declarations and typesparameter packsFeature → generics: Parameter packsswift 5.9unexpected errorBug: Unexpected error

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions