Re: [swift-dev] Needs better error msg?

2016-09-20 Thread Mark Lacey via swift-dev

> On Sep 20, 2016, at 2:05 PM, Joe Groff via swift-dev  
> wrote:
> 
>> 
>> On Sep 20, 2016, at 1:45 PM, Kevin Choi via swift-dev  
>> wrote:
>> 
>> b.sw:
>> func findIndex(array: [T], _ valueToFind: T) -> Int? {
>>for (index, value) in array.enumerated() {
>>if value == valueToFind {
>>return index
>>}
>>}
>>return nil
>> }
>> 
>> let foundAtIndex = findIndex([1, 2, 3, 4], 3)
>> print(foundAtIndex == 2) // true
>> 
>> ===
>> ~/git/swift-source$ 
>> build/Ninja-RelWithDebInfoAssert/swift-linux-x86_64/bin/swift b.sw
>> b.sw:10:44: error: unnamed argument #2 must precede unnamed argument #1
>> let foundAtIndex = findIndex([1, 2, 3, 4], 3)
>>   ^
>> 3 [1, 2, 3, 4]
>> 
>> The error seems to arise from the requirement:
>>> If a parameter has an argument label, the argument must be labeled when you 
>>> call the function.
>> 
>> Instead the shown error assumes the order is swapped because first argument 
>> was unnamed. Should the former (from requirement) be shown as the error here?
> 
> Yeah, that would make much more sense. If you have a moment, would you be 
> able to report this as a bug on bugs.swift.org ?

I believe we already have one: https://bugs.swift.org/browse/SR-2242.

Mark

> 
> -Joe
> ___
> swift-dev mailing list
> swift-dev@swift.org 
> https://lists.swift.org/mailman/listinfo/swift-dev 
> 
___
swift-dev mailing list
swift-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-dev


Re: [swift-dev] Needs better error msg?

2016-09-20 Thread Joe Groff via swift-dev

> On Sep 20, 2016, at 1:45 PM, Kevin Choi via swift-dev  
> wrote:
> 
> b.sw:
> func findIndex(array: [T], _ valueToFind: T) -> Int? {
> for (index, value) in array.enumerated() {
> if value == valueToFind {
> return index
> }
> }
> return nil
> }
> 
> let foundAtIndex = findIndex([1, 2, 3, 4], 3)
> print(foundAtIndex == 2) // true
> 
> ===
> ~/git/swift-source$ 
> build/Ninja-RelWithDebInfoAssert/swift-linux-x86_64/bin/swift b.sw
> b.sw:10:44: error: unnamed argument #2 must precede unnamed argument #1
> let foundAtIndex = findIndex([1, 2, 3, 4], 3)
>    ^
>  3 [1, 2, 3, 4]
> 
> The error seems to arise from the requirement:
> > If a parameter has an argument label, the argument must be labeled when you 
> > call the function.
> 
> Instead the shown error assumes the order is swapped because first argument 
> was unnamed. Should the former (from requirement) be shown as the error here?

Yeah, that would make much more sense. If you have a moment, would you be able 
to report this as a bug on bugs.swift.org?

-Joe
___
swift-dev mailing list
swift-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-dev


[swift-dev] Needs better error msg?

2016-09-20 Thread Kevin Choi via swift-dev
b.sw:
func findIndex(array: [T], _ valueToFind: T) -> Int? {
for (index, value) in array.enumerated() {
if value == valueToFind {
return index
}
}
return nil
}

let foundAtIndex = findIndex([1, 2, 3, 4], 3)
print(foundAtIndex == 2) // true

===
~/git/swift-source$
build/Ninja-RelWithDebInfoAssert/swift-linux-x86_64/bin/swift b.sw
b.sw:10:44: error: unnamed argument #2 must precede unnamed argument #1
let foundAtIndex = findIndex([1, 2, 3, 4], 3)
   ^
 3 [1, 2, 3, 4]

The error seems to arise from the requirement:
> If a parameter has an argument label, the argument *must* be labeled when
you call the function.

Instead the shown error assumes the order is swapped because first argument
was unnamed. Should the former (from requirement) be shown as the error
here?

-Kevin
___
swift-dev mailing list
swift-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-dev