Skip to content

[SR-6305] Cannot initialise Dictionary from an EnumeratedSequence #48855

@karwa

Description

@karwa
Previous ID SR-6305
Radar rdar://problem/37159993
Original Reporter @karwa
Type Bug
Environment

Apple Swift version 4.0.3 (swiftlang-900.0.71 clang-900.0.38)

Target: x86_64-apple-macosx10.9

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, TypeChecker
Assignee @xedin
Priority Medium

md5: a219796b79b304ec98d478ac6a4adc11

is duplicated by:

  • SR-6905 Dictionary(uniqueKeysWithValues:) does not accept sequence of labeled tuples

Issue Description:

The following snippet fails to compile:

let test = Dictionary(uniqueKeysWithValues: ["a", "b", "c"].enumerated())

With the message:

Cannot invoke initializer for type 'Dictionary<_, _>' with an argument list of type '(uniqueKeysWithValues: EnumeratedSequence<[String]>)'

The only way I was able to get it to work was to add a pass-through call to "map" on the end:

let test = Dictionary(uniqueKeysWithValues: ["a", "b", "c"].enumerated().map { $0 })

Metadata

Metadata

Assignees

Labels

bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselftype checkerArea → compiler: Semantic analysis

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions