Kitura-net icon indicating copy to clipboard operation
Kitura-net copied to clipboard

'Error' is ambiguous for type lookup in this context.

Open JinHo-C opened this issue 7 years ago • 4 comments

Hello,

When I import Kitura-net (KituraNet), I get errors like below.

'Error' is ambiguous for type lookup in this context.

KituraNet causes this error because it has a "public" enum named Error on Error.swift.

As you know, Swift 3 uses Error instead of NSError now.

So, I think it should be fixed.

JinHo-C avatar Mar 27 '17 14:03 JinHo-C

@JinHo-C Replacing Error with Swift.Error in your code to avoid the conflict with KituraNet.Error should fix the problem.

na-gupta avatar Apr 17 '17 18:04 na-gupta

We should slate a name change for the next major version release. If another library is extending from Error without specifying Swift.Error, and the application imports both that library and Kitura-net, then this issue will still come up.

youming-lin avatar Apr 17 '17 19:04 youming-lin

I agree it's probably a better design decision to name things so they don't conflict with the standard library.

However, if another library defines an enum or class called Error that adopts Error without specifying Swift.Error, that should cause a compile error:

error: circular enum raw types Error
public enum Error: Error {
            ^
error: circular class inheritance Error
public class Error: Error {
             ^

na-gupta avatar Apr 17 '17 19:04 na-gupta

I was thinking of a namespace issue, but I guess in my example it's not an issue due to the third party library not having a dependency on Kitura-net.

youming-lin avatar Apr 17 '17 19:04 youming-lin