beta4: [1]==[1] errors

80 views
Skip to first unread message

Adam Strzelecki

unread,
Jul 22, 2014, 7:57:21 AM7/22/14
to swift-l...@googlegroups.com
Hi,

It seems that beta4 made comparisons even worse again, heres what I get in "xcrun swift":

$ xcrun swift
Welcome to Swift! Type :help for assistance.
1> 1+1
$R0: Int = 2
2> [1]==[1]
/var/folders/8y/fkcsg_7x47s5gv7gjj11mmhh0000gn/T//lldb/21958/expr.INt9vV.swift:2:4: error: ambiguous use of operator '=='
[1]==[1]
^
Swift.==:1:6: note: found this candidate
func ==<T : Equatable>(lhs: Array<T>, rhs: Array<T>) -> Bool
^
Swift.==:1:19: note: found this candidate
@transparent func ==<T>(lhs: ConstUnsafePointer<T>, rhs: ConstUnsafePointer<T>) -> Bool
^

2> import Cocoa
3> [1]==[1]
/var/folders/8y/fkcsg_7x47s5gv7gjj11mmhh0000gn/T//lldb/21958/expr.kfZ9eh.swift:2:1: error: 'MirrorDisposition' does not have a member named 'Element'
[1]==[1]
^


Any reason it doesn't work and generates such a weird messages?

--Adam

Chris Lattner

unread,
Jul 22, 2014, 12:13:03 PM7/22/14
to Adam Strzelecki, swift-l...@googlegroups.com
This occurs because both the LHS and RHS of the comparison work with both Array<Int> and UnsafeConstPointer<Int>. If you compare [1] to something of a concrete type, this error will not occur.

-Chris

Adam Strzelecki

unread,
Jul 22, 2014, 5:57:53 PM7/22/14
to Chris Lattner, swift-l...@googlegroups.com
> This occurs because both the LHS and RHS of the comparison work with both Array<Int> and UnsafeConstPointer<Int>. If you compare [1] to something of a concrete type, this error will not occur.

I may probably misunderstood something, but what makes [1] non-concrete? Isn't it just an instance of [Int] aka Array<Int>?

Why this works:
let a = [1]
a == [1]

But this doesn't:
[1] == [1]
[1] == a

--Adam

Adam Strzelecki

unread,
Aug 4, 2014, 4:41:24 PM8/4/14
to Chris Lattner, swift-l...@googlegroups.com
Works in Beta 5, no errors, good work!

Thank you,
--
Adam
Reply all
Reply to author
Forward
0 new messages