File tree Expand file tree Collapse file tree 2 files changed +10
-5
lines changed Expand file tree Collapse file tree 2 files changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -5863,12 +5863,16 @@ bool OutOfOrderArgumentFailure::diagnoseAsError() {
5863
5863
5864
5864
// Move requires postfix comma only if argument is moved in-between
5865
5865
// other arguments.
5866
- bool requiresComma =
5867
- !isExpr<BinaryExpr>(anchor) && PrevArgIdx != args->size () - 1 ;
5866
+ std::string argumentSeparator;
5867
+ if (auto *BE = getAsExpr<BinaryExpr>(anchor)) {
5868
+ auto operatorName = std::string (*getOperatorName (BE->getFn ()));
5869
+ argumentSeparator = " " + operatorName + " " ;
5870
+ } else if (PrevArgIdx != args->size () - 1 ) {
5871
+ argumentSeparator = " , " ;
5872
+ }
5868
5873
5869
5874
diag.fixItRemove (removalRange);
5870
- diag.fixItInsert (secondRange.Start ,
5871
- text.str () + (requiresComma ? " , " : " " ));
5875
+ diag.fixItInsert (secondRange.Start , text.str () + argumentSeparator);
5872
5876
};
5873
5877
5874
5878
// There are 4 diagnostic messages variations depending on
Original file line number Diff line number Diff line change @@ -82,7 +82,8 @@ var _ : TheDevil = God()^
82
82
var _ : God = ^TheDevil( )
83
83
var _ : Man = TheDevil ( ) ^ God ( )
84
84
var _ : Man = God ( ) ^ ^ ^TheDevil ( )
85
- let _ = God ( ) ^TheDevil ( ) // expected-error{{operator argument #2 must precede operator argument #1}} {{9-9=TheDevil()}} {{14-25=}}
85
+ let _ = God ( ) ^TheDevil ( ) // expected-error{{operator argument #2 must precede operator argument #1}} {{9-9=TheDevil() ^ }} {{14-25=}}
86
+ let _ = God ( ) ^ TheDevil ( ) // expected-error{{operator argument #2 must precede operator argument #1}} {{9-9=TheDevil() ^ }} {{14-27=}}
86
87
87
88
postfix func ^ ( x: Man ) -> ( ) -> God {
88
89
return { return God ( ) }
You can’t perform that action at this time.
0 commit comments