Re: [swift-evolution] When exactly 1 function matches a call site, should it be called or cause a compiler error?

2017-11-12 Thread Slava Pestov via swift-evolution
> On Nov 12, 2017, at 7:27 PM, Nevin Brackett-Rozinsky > wrote: > > On Sun, Nov 12, 2017 at 10:16 PM, Slava Pestov > wrote: >> Pardon my lack of imagination, but could you provide an example of a call >> site

Re: [swift-evolution] When exactly 1 function matches a call site, should it be called or cause a compiler error?

2017-11-12 Thread Nevin Brackett-Rozinsky via swift-evolution
On Sun, Nov 12, 2017 at 10:16 PM, Slava Pestov wrote: > > Pardon my lack of imagination, but could you provide an example of a call > site that would become ambiguous? > > > protocol P {} > protocol Q {} > struct S : P, Q {} > > struct Outer { > static func foo(_: P) {} > >

Re: [swift-evolution] When exactly 1 function matches a call site, should it be called or cause a compiler error?

2017-11-12 Thread Slava Pestov via swift-evolution
> On Nov 12, 2017, at 7:14 PM, Nevin Brackett-Rozinsky > wrote: > > On Sun, Nov 12, 2017 at 8:44 PM, Slava Pestov > wrote: > Yeah, this is an unfortunate wart. Right now unqualified lookup starts at the >

Re: [swift-evolution] When exactly 1 function matches a call site, should it be called or cause a compiler error?

2017-11-12 Thread Nevin Brackett-Rozinsky via swift-evolution
On Sun, Nov 12, 2017 at 8:44 PM, Slava Pestov wrote: > Yeah, this is an unfortunate wart. Right now unqualified lookup starts at > the innermost scope and stops when it finds a candidate which matches the > name being looked up. Overload sets are only formed if there are

Re: [swift-evolution] When exactly 1 function matches a call site, should it be called or cause a compiler error?

2017-11-12 Thread Slava Pestov via swift-evolution
Yeah, this is an unfortunate wart. Right now unqualified lookup starts at the innermost scope and stops when it finds a candidate which matches the name being looked up. Overload sets are only formed if there are multiple candidates inside the same scope, not in different scopes. It would be

[swift-evolution] When exactly 1 function matches a call site, should it be called or cause a compiler error?

2017-11-12 Thread Nevin Brackett-Rozinsky via swift-evolution
I brought this up on Swift Dev and was told to check on Swift Evolution to see if a proposal is needed. Currently, the following code produces a compiler error: func foo(_ x: Int, _ y: Int) -> Int { return x + y } extension Int { func foo() -> Int { return foo(self, self)// Error