Uploaded image for project: 'Swift'
  1. Swift
  2. SR-6305

Cannot initialise Dictionary from an EnumeratedSequence

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: Medium
    • Resolution: Unresolved
    • Component/s: Compiler
    • Labels:
    • Environment:

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

      Target: x86_64-apple-macosx10.9

      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 })
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              xedin Pavel Yaskevich
              Reporter:
              kawa Karl
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated: