swiftlang / swift

The Swift Programming Language
https://swift.org
Apache License 2.0
66.77k stars 10.29k forks source link

Code completion is not suggesting argument label of existing argument #71189

Open ahoppen opened 5 months ago

ahoppen commented 5 months ago

The following test case only suggests lineCap and not dash, which is causing a stress tester failure. One could argue that the current behavior is expected, which would mean that the stress tester needs to be updated.

func test(lineCap: Int = 1, dash: Int = 1) {}
test(#^COMPLETE^# dash: 1)

This change in behavior is caused by https://github.com/apple/swift/pull/71054

rintaro commented 5 months ago

Hm, I didn't think about it deeply when I reviewed the PR, but I believe suggesting the entire call pattern was the expected behavior, because for example:

func foo(arg: Int, option: Opiton) -> Int
func bar(arg: Int, option: Option) -> Int

bar(arg: foo(#^COMPLETE^#, option: .default)

we can't decide the option: .default was meant for foo call, or the outer bar call.