hlovatt
(Howard Lovatt)
September 5, 2017, 1:54am
1
Hi All,
Is this a compiler bug?
struct Box<T> {
var value: T
init(_ value: T) { self.value = value }
/// Unboxing operator.
static func >> <T>(left: Box<T>, right: inout T?) {
right = left.value
}
}
var u: String?
let b = Box("Test")
b >> &u // ERROR: Cannot convert value of type 'Box<String>' to expected
argument type 'Box<_>'
Am I missing something?
Thanks in advance for any help,
-- Howard.
Yeah, looks like a bug. Do you mind filing a JIRA?
Slava
···
On Sep 4, 2017, at 8:55 PM, Howard Lovatt via swift-users <swift-users@swift.org> wrote:
Hi All,
Is this a compiler bug?
struct Box<T> {
var value: T
init(_ value: T) { self.value = value }
/// Unboxing operator.
static func >> <T>(left: Box<T>, right: inout T?) {
right = left.value
}
}
var u: String?
let b = Box("Test")
b >> &u // ERROR: Cannot convert value of type 'Box<String>' to expected argument type 'Box<_>'
Am I missing something?
Thanks in advance for any help,
-- Howard.
_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users
hlovatt
(Howard Lovatt)
September 5, 2017, 2:23am
3
Thanks for prompt reply - link is:
opened 03:22AM - 05 Sep 17 UTC
bug
compiler
type checker
| | |
|------------------|-----------------|…
|Previous ID | SR-5838 |
|Radar | None |
|Original Reporter | hlovatt (JIRA User) |
|Type | Bug |
Attachment: [Download](https://user-images.githubusercontent.com/2727770/164962311-b9920e24-4501-475e-b372-aa44c82896ac.gz)
<details>
<summary>Environment</summary>
MacOS 10.12.6
Xcode 9 beta 6
</details>
<details>
<summary>Additional Detail from JIRA</summary>
| | |
|------------------|-----------------|
|Votes | 0 |
|Component/s | Compiler |
|Labels | Bug, TypeChecker |
|Assignee | @xedin |
|Priority | Medium |
md5: e1f37be7e1af0d30689c36d19ce7d871
</details>
**relates to**:
* [SR-1420](https://bugs.swift.org/browse/SR-1420) Provide compiler warning when shadowing generic type
**Issue Description:**
See attached playground.
The compiler can't infer the type of the argument to the operator.
Seems to only be a problem with inout parameters and operators.
-- Howard.
···
On 5 September 2017 at 11:58, Slava Pestov <spestov@apple.com> wrote:
Yeah, looks like a bug. Do you mind filing a JIRA?
Slava
On Sep 4, 2017, at 8:55 PM, Howard Lovatt via swift-users < > swift-users@swift.org> wrote:
Hi All,
Is this a compiler bug?
struct Box<T> {
var value: T
init(_ value: T) { self.value = value }
/// Unboxing operator.
static func >> <T>(left: Box<T>, right: inout T?) {
right = left.value
}
}
var u: String?
let b = Box("Test")
b >> &u // ERROR: Cannot convert value of type 'Box<String>' to expected
argument type 'Box<_>'
Am I missing something?
Thanks in advance for any help,
-- Howard.
_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users