Skip to content

Commit 9067ed2

Browse files
committed
[ConstraintSystem] Specialize diagnostic for ~= to talk about expression pattern use
1 parent ac2305e commit 9067ed2

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

lib/Sema/ConstraintSystem.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2814,6 +2814,9 @@ static void diagnoseOperatorAmbiguity(ConstraintSystem &cs,
28142814
operatorName.str());
28152815
return;
28162816
}
2817+
} else if (operatorName.is("~=")) {
2818+
DE.diagnose(anchor->getLoc(), diag::cannot_match_expr_pattern_with_value,
2819+
lhsType, rhsType);
28172820
} else {
28182821
DE.diagnose(anchor->getLoc(), diag::cannot_apply_binop_to_args,
28192822
operatorName.str(), lhsType, rhsType)

test/Parse/switch.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,7 @@ func f1(x: String, y: Whichever) {
336336
case Whichever.buzz: // expected-error {{type 'Whichever' has no member 'buzz'}}
337337
break
338338
case Whichever.alias: // expected-error {{expression pattern of type 'Whichever' cannot match values of type 'String'}}
339+
// expected-note@-1 {{overloads for '~=' exist with these partially matching parameter lists: (Substring, String)}}
339340
break
340341
default:
341342
break

0 commit comments

Comments
 (0)