Skip to content

Commit 5c536d6

Browse files
committed
Fix the type of postfix ... operator in the ambiguity example.
1 parent c9574be commit 5c536d6

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

proposals/NNNN-parameter-packs.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ func ranges<T..., U...>(values: T..., otherValues: U...) where T: Comparable, le
388388

389389
In the above code, `values...` in the expansion pattern could mean either:
390390

391-
1. The postfix `...` operator is called on each element in `values`, and the result is expanded pairwise with `otherValues` such that each argument has type `(ClosedRange<T>, U)`
391+
1. The postfix `...` operator is called on each element in `values`, and the result is expanded pairwise with `otherValues` such that each argument has type `(PartialRangeFrom<T>, U)`
392392
2. `values` is expanded into each tuple passed to `acceptAnything`, with each element of `otherValues` appended onto the end of the tuple, and each argument has type `(T... U)`
393393

394394
Like the ambiguity with non-pack variadic parameters, the pack expansion interpretation of `...` is preferred in expressions. This corresponds to the second meaning above. It is still possible to write code with the first meaning, by factoring out the call to the postfix closed-range operator into a function:
@@ -397,11 +397,11 @@ Like the ambiguity with non-pack variadic parameters, the pack expansion interpr
397397
func acceptAnything<T...>(_: T...) {}
398398

399399
func ranges<T..., U...>(values: T..., otherValues: U...) where T: Comparable, length(Ts...) == length(Us...) {
400-
func range<C: Comparable>(from comparable: C) -> ClosedRange<C> {
400+
func range<C: Comparable>(from comparable: C) -> PartialRangeFrom<C> {
401401
return comparable...
402402
}
403403

404-
acceptAnything((range(from: values)..., otherValues)...)
404+
acceptAnything((range(from: values), otherValues)...)
405405
}
406406
```
407407

0 commit comments

Comments
 (0)