Commit Graph

13 Commits

Author SHA1 Message Date
Alex Hoppen
fa9f3f3337 [Sema] Correctly diagnose passing tuple as only argument to function with multiple parameters
If a tuple is passed as the only argument to a function that takes two unnamed arguments, we try to diagnose the missing argument label. However, in the old diagnose code we didn’t distinguish between non-existing arguments and arguments without labels; both behaved the same.

Thus, the missing second argument in the function call would line up with the empty second argument label, not producing a diagnostic, but hitting an assertion later on.

Distinguish between the two to fix the issue.

Fixes rdar://64319340
2021-03-19 12:58:17 +01:00
Pavel Yaskevich
e086896f24 [Diagnostics] Avoid adding comma when reordering with last argument 2021-01-19 13:37:43 -08:00
Pavel Yaskevich
09f3461e3d [Diagnostics] Adjust OoO fix-it intervals to account for replacement of first argument
Current logic fix-it didn't account for the first argument being re-ordered.
The start position for the first argument should always be the next token
after left paren denoting a start of the argument list.

Resolves: rdar://problem/70764991
2021-01-19 13:37:32 -08:00
Owen Voorhees
9708247065 [SE-0284] Lift the 1-vararg-per-function restriction
[SE-0284] Add round_trip_parse_gen tests

[SE-0284] Add missing test cases
2020-08-23 21:37:07 -07:00
Doug Gregor
2395225df7 [Type checker] Improve diagnostics for trailing closures.
The change to the forward-scanning rule regressed some diagnostics,
because we no longer generated the special "trailing closure mismatch"
diagnostic. Reinstate the special-case "trailing closure mismatch"
diagnostic, but this time do so as part of the normal argument
mismatch diagnostics so it is based on type information.

While here, clean up the handling of missing-argument diagnostics to
deal with (multiple) trailing closures properly, so that we can (e.g)
suggest adding a new labeled trailing closure at the end, rather than
producing nonsensical Fix-Its.

And, note that SR-12291 is broken (again) by the forward-scan matching
rules.
2020-07-24 08:10:54 -07:00
Luciano Almeida
12c8630f7f [tests] Adding regression tests for SR-13240 2020-07-23 20:04:55 -03:00
Pavel Yaskevich
739ba4bb39 [CSBindings] Open collection binding associated with @autoclosure argument
To preserve subtype relationship between element types of a collection
passed as an argument to a parameter represented by another collection
type let's extend opening of the collection types to be done for arguments
to @autoclosure parameters as well because implicit closure is transparent
to the caller.

Resolves: [SR-13135](https://bugs.swift.org/browse/SR-13135)
Resolves: rdar://problem/65088975
2020-07-06 11:54:39 -07:00
Pavel Yaskevich
c0840fdcd3 [TypeChecker] NFC: Restore test-cases removed by incorrect merge 2020-06-12 15:07:32 -07:00
Pavel Yaskevich
d9594c712a [TypeChecker] NFC: Adjust tests improved by new approach for ambiguity diagnosis 2020-06-12 11:47:03 -07:00
omochimetaru
21c9996a1f [ConstraintSystem][NFC] add test cases for argument matching 2020-05-30 22:58:45 +09:00
omochimetaru
8339e8ccd0 [ConstraintSystem][NFC] add tests for label matching diagnostics
It bakes current behavior for reviewing changes in future.
2020-05-24 06:54:07 +09:00
omochimetaru
339f179731 [ConstraintSystem][NFC] Move test cases about argument matching ...
from `diagnostics.swift` to `argument_matching.swift` which has
more specific interest.
2020-05-23 06:15:13 +09:00
omochimetaru
a6d97ecade [ConstraintSystem][NFC] rename keyword_arguments.swift to ...
`argument_matching.swift` in test.

New filename indicates that is also contains a test case for
matching of unlabeled arguments.
2020-05-23 05:40:36 +09:00