Skip to content

"Ambiguous without more context" using parameter packs and key-paths #66502

Closed
@hborla

Description

@hborla

The following code produces Type of expression is ambiguous without more context

func configure<T, each Element>(
  _ item: T,
  with configuration: repeat (ReferenceWritableKeyPath<T, each Element>, each Element)
) -> T {
  repeat item[keyPath: (each configuration).0] = (each configuration).1 // error: Type of expression is ambiguous without more context
  return item
}

This should compile successfully.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfexpressionsFeature: expressionsgenericsFeature: generic declarations and typeskey pathsFeature: key paths (both native and Objective-C)parameter packsFeature → generics: Parameter packsswift 5.9tuplesFeature: tuplestype checkerArea → compiler: Semantic analysisunexpected errorBug: Unexpected error

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions