`initial` variable in `reduce` loses tuple labels.
| Originator: | jdhealy | ||
| Number: | rdar://21373612 | Date Originated: | 13-Jun-2015 07:14 PM |
| Status: | Open | Resolved: | |
| Product: | Developer Tools | Product Version: | swiftlang-700.0.38.1 |
| Classification: | Serious Bug | Reproducible: | Always |
Summary:
Accessing tuple indexes via labels results in a `does not have a member named` error.
Steps to Reproduce:
1.
```swift
let (one, two) = [ Void() ].reduce(
(one: 1, two: 2)
) { previous, value in
_ = previous.one
return (previous.one, previous.two)
}
```
Expected Results:
It should compile.
Actual Results:
```
error: libarclite_macosx.a(arclite.o) failed to load objfile for /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/arc/libarclite_macosx.a
Welcome to Apple Swift version 2.0 (700.0.38.1 700.0.53). Type :help for assistance.
repl.swift:4:7: error: '(Int, Int)' does not have a member named 'one'
_ = previous.one
^ ~~~
repl.swift:5:10: error: '(Int, Int)' does not have a member named 'one'
return (previous.one, previous.two)
^ ~~~
```
Regression:
With Swift 1.2 — `swiftlang-602.0.53.1`, the first code block compiles.
Notes:
With Swift 2.0 — `swiftlang-700.0.38.1`, this compiles:
```swift
let (one, two) = [ Void() ].reduce(
(one: 1, two: 2)
) { previous, value in
// _ = previous.one // commented this line out
return (previous.one, previous.two)
}
```
With Swift 2.0 — `swiftlang-700.0.38.1`, this **does not** compile:
```swift
let (one, two) = [ Void() ].reduce(
(one: 1, two: 2)
) { previous, value in
_ = previous.0
return (previous.one, previous.two)
}
```
With Swift 2.0 — `swiftlang-700.0.38.1`, this compiles:
```swift
let (one, two) = [ Void() ].reduce(
(one: 1, two: 2)
) { previous, value in
_ = previous.0
return (previous.0, previous.1)
}
```
With Swift 2.0 — `swiftlang-700.0.38.1`, this compiles:
```swift
let (one, two) = [ Void() ].reduce(
(one: 1, two: 2)
) { (previous: (one: Int, two: Int), value) in
_ = previous.one
return (previous.one, previous.two)
}
```
See in practice: <https://github.com/jdhealy/PrettyColors/commit/7a1682b7663cfa075d8e9a5ad0c1e096e54968b5>
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!