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() {
58635863
58645864 // Move requires postfix comma only if argument is moved in-between
58655865 // 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+ }
58685873
58695874 diag.fixItRemove (removalRange);
5870- diag.fixItInsert (secondRange.Start ,
5871- text.str () + (requiresComma ? " , " : " " ));
5875+ diag.fixItInsert (secondRange.Start , text.str () + argumentSeparator);
58725876 };
58735877
58745878 // 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()^
8282var _ : God = ^TheDevil( )
8383var _ : Man = TheDevil ( ) ^ God ( )
8484var _ : 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=}}
8687
8788postfix func ^ ( x: Man ) -> ( ) -> God {
8889 return { return God ( ) }
You can’t perform that action at this time.
0 commit comments