Skip to content

Commit cfb9e5e

Browse files
committed
Sema: Update diagnostics for openType() change
Some of these are minor regressions; they will be fixed on main but not release/5.10.
1 parent eb67b1f commit cfb9e5e

File tree

2 files changed

+27
-30
lines changed

2 files changed

+27
-30
lines changed

test/Constraints/pack-expansion-expressions.swift

Lines changed: 25 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,8 @@ func tupleExpansion<each T, each U>(
139139
_ = zip(repeat each tuple1, with: repeat each tuple1.element) // legacy syntax
140140

141141
_ = zip(repeat each tuple1, with: repeat each tuple2)
142-
// expected-error@-1 {{global function 'zip(_:with:)' requires the type packs 'repeat each T' and 'repeat each U' have the same shape}}
142+
// expected-error@-1 {{global function 'zip(_:with:)' requires the type packs 'each T' and 'each U' have the same shape}}
143+
// expected-error@-2 {{pack expansion requires that 'each U' and 'each T' have the same shape}}
143144

144145
_ = forward(repeat each tuple3)
145146
}
@@ -349,37 +350,36 @@ func test_pack_expansions_with_closures() {
349350
func test_pack_expansion_specialization(tuple: (Int, String, Float)) {
350351
struct Data<each T> {
351352
init(_: repeat each T) {} // expected-note 4 {{'init(_:)' declared here}}
352-
init(vals: repeat each T) {} // expected-note {{'init(vals:)' declared here}}
353-
init<each U>(x: Int, _: repeat each T, y: repeat each U) {} // expected-note 3 {{'init(x:_:y:)' declared here}}
353+
init(vals: repeat each T) {}
354+
init<each U>(x: Int, _: repeat each T, y: repeat each U) {}
354355
}
355356

356357
_ = Data<Int>() // expected-error {{missing argument for parameter #1 in call}}
357358
_ = Data<Int>(0) // Ok
358359
_ = Data<Int, String>(42, "") // Ok
359-
_ = Data<Int>(42, "") // expected-error {{extra argument in call}}
360+
_ = Data<Int>(42, "") // expected-error {{pack expansion requires that 'Int' and 'Int, String' have the same shape}}
360361
_ = Data<Int, String>((42, ""))
361-
// expected-error@-1 {{value pack expansion at parameter #0 expects 2 separate arguments; remove extra parentheses to change tuple into separate arguments}} {{25-26=}} {{32-33=}}
362+
// expected-error@-1 {{initializer expects 2 separate arguments; remove extra parentheses to change tuple into separate arguments}} {{25-26=}} {{32-33=}}
362363
_ = Data<Int, String, Float>(vals: (42, "", 0))
363-
// expected-error@-1 {{value pack expansion at parameter #0 expects 3 separate arguments; remove extra parentheses to change tuple into separate arguments}} {{38-39=}} {{48-49=}}
364+
// expected-error@-1 {{pack expansion requires that 'Int, String, Float' and '(Int, String, Int)' have the same shape}}
364365
_ = Data<Int, String, Float>((vals: 42, "", 0))
365-
// expected-error@-1 {{value pack expansion at parameter #0 expects 3 separate arguments; remove extra parentheses to change tuple into separate arguments}} {{32-33=}} {{48-49=}}
366+
// expected-error@-1 {{initializer expects 3 separate arguments; remove extra parentheses to change tuple into separate arguments}} {{32-33=}} {{48-49=}}
366367
_ = Data<Int, String, Float>(tuple)
367-
// expected-error@-1 {{value pack expansion at parameter #0 expects 3 separate arguments}}
368+
// expected-error@-1 {{initializer expects 3 separate arguments}}
368369
_ = Data<Int, String, Float>(x: 42, tuple)
369-
// expected-error@-1 {{value pack expansion at parameter #1 expects 3 separate arguments}}
370+
// expected-error@-1 {{pack expansion requires that 'Int, String, Float' and '(Int, String, Float)' have the same shape}}
370371
_ = Data<Int, String, Float>(x: 42, tuple, y: 1, 2, 3)
371-
// expected-error@-1 {{value pack expansion at parameter #1 expects 3 separate arguments}}
372+
// expected-error@-1 {{pack expansion requires that 'Int, String, Float' and '(Int, String, Float)' have the same shape}}
372373
_ = Data<Int, String, Float>(x: 42, (42, "", 0), y: 1, 2, 3)
373-
// expected-error@-1 {{value pack expansion at parameter #1 expects 3 separate arguments}} {{39-40=}} {{49-50=}}
374+
// expected-error@-1 {{pack expansion requires that 'Int, String, Float' and '(Int, String, Int)' have the same shape}}
374375

375376
struct Ambiguity<each T> {
376377
func test(_: repeat each T) -> Int { 42 }
377-
// expected-note@-1 {{value pack expansion at parameter #0 expects 3 separate arguments}}
378+
// expected-note@-1 {{'test' declared here}}
378379
func test(_: repeat each T) -> String { "" }
379-
// expected-note@-1 {{value pack expansion at parameter #0 expects 3 separate arguments}}
380380
}
381381

382-
_ = Ambiguity<Int, String, Float>().test(tuple) // expected-error {{no exact matches in call to instance method 'test'}}
382+
_ = Ambiguity<Int, String, Float>().test(tuple) // expected-error {{instance method 'test' expects 3 separate arguments}}
383383
}
384384

385385
// rdar://107280056 - "Ambiguous without more context" with opaque return type + variadics
@@ -621,44 +621,40 @@ do {
621621
// https://github.com/apple/swift/issues/66393
622622
do {
623623
struct S<each T> {
624-
var property: (repeat each T) -> Void { // expected-note 4 {{'property' declared here}}
624+
var property: (repeat each T) -> Void {
625625
get {}
626626
}
627627

628-
func method(_: repeat each T) {} // expected-note 4 {{'method' declared here}}
628+
func method(_: repeat each T) {}
629629
}
630630
S<Int, Bool>().method((5, true))
631-
// expected-error@-1 {{value pack expansion at parameter #0 expects 2 separate arguments; remove extra parentheses to change tuple into separate arguments}}
631+
// expected-error@-1 {{pack expansion requires that 'Int, Bool' and '(Int, Bool)' have the same shape}}
632632

633633
S<Int, Bool>().method((5, true, 6))
634-
// expected-error@-1 {{value pack expansion at parameter #0 expects 2 separate arguments; remove extra parentheses to change tuple into separate arguments}}
634+
// expected-error@-1 {{pack expansion requires that 'Int, Bool' and '(Int, Bool, Int)' have the same shape}}
635635

636636
S<Int, Bool>().property((5, true))
637-
// expected-error@-1 {{value pack expansion at parameter #0 expects 2 separate arguments; remove extra parentheses to change tuple into separate arguments}}
637+
// expected-error@-1 {{cannot pass value pack expansion to non-pack parameter of type 'repeat each T'}}
638638

639639
S<Int, Bool>().property((5, true, 6))
640-
// expected-error@-1 {{value pack expansion at parameter #0 expects 2 separate arguments; remove extra parentheses to change tuple into separate arguments}}
640+
// expected-error@-1 {{cannot pass value pack expansion to non-pack parameter of type 'repeat each T'}}
641641

642642
func foo<each U>(u: repeat each U) {
643643
S<repeat each U>().property((3, 4, 5))
644-
// expected-error@-1 {{value pack expansion at parameter #0 expects 1 separate arguments; remove extra parentheses to change tuple into separate arguments}}
644+
// expected-error@-1 {{cannot pass value pack expansion to non-pack parameter of type 'repeat each T'}}
645645

646646
// FIXME: The count of 'repeat each U' is not statically known, but error suggests that it is 1.
647647
S<repeat each U>().method((3, 4, 5))
648-
// expected-error@-1 {{value pack expansion at parameter #0 expects 1 separate arguments; remove extra parentheses to change tuple into separate arguments}}
649-
// FIXME: Bad diagnostics
650-
// expected-error@-3 {{pack expansion requires that 'each U' and '_' have the same shape}}
651-
// expected-error@-4 {{pack expansion requires that 'each U' and '_.RawValue' have the same shape}}
648+
// expected-error@-1 {{pack expansion requires that 'each U' and '(Int, Int, Int)' have the same shape}}
652649

653650
// FIXME: The count of '(Int, Int), repeat each U' is not statically known, but error suggests that it is 2.
654651
S<(Int, Int), repeat each U>().method((3, 4))
655-
// expected-error@-1 {{value pack expansion at parameter #0 expects 2 separate arguments; remove extra parentheses to change tuple into separate arguments}}
656-
// FIXME: Duplicate diagnostics
657-
// expected-error@-3 2 {{pack expansion requires that 'each U' and '' have the same shape}}
652+
// expected-error@-1 {{pack expansion requires that '(Int, Int), repeat each U' and '(Int, Int)' have the same shape}}
653+
// expected-error@-2 {{pack expansion requires that '' and 'each U' have the same shape}}
658654

659655
// FIXME: The count of '(Int, Int), repeat each U' is not statically known, but error suggests that it is 2.
660656
S<(Int, Int), repeat each U>().property((3, 4))
661-
// expected-error@-1 {{value pack expansion at parameter #0 expects 2 separate arguments; remove extra parentheses to change tuple into separate arguments}}
657+
// expected-error@-1 {{cannot pass value pack expansion to non-pack parameter of type 'repeat each T'}}
662658
}
663659
}
664660

test/Constraints/variadic_generic_constraints.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,5 +73,6 @@ func goodCallToZip<each T, each U>(t: repeat each T, u: repeat each U) where (re
7373

7474
func badCallToZip<each T, each U>(t: repeat each T, u: repeat each U) {
7575
_ = zip(t: repeat each t, u: repeat each u)
76-
// expected-error@-1 {{global function 'zip(t:u:)' requires the type packs 'repeat each T' and 'repeat each U' have the same shape}}
76+
// expected-error@-1 {{global function 'zip(t:u:)' requires the type packs 'each T' and 'each U' have the same shape}}
77+
// expected-error@-2 {{pack expansion requires that 'each U' and 'each T' have the same shape}}
7778
}

0 commit comments

Comments
 (0)