@@ -378,9 +378,9 @@ capture_op_eol -> capture_op : '$1'.
378
378
capture_op_eol -> capture_op eol : '$1' .
379
379
380
380
unary_op_eol -> unary_op : '$1' .
381
- unary_op_eol -> unary_op eol : '$1' .
381
+ unary_op_eol -> unary_op eol : warn_unary_operator_eol ( '$1' ), '$1' .
382
382
unary_op_eol -> dual_op : '$1' .
383
- unary_op_eol -> dual_op eol : '$1' .
383
+ unary_op_eol -> dual_op eol : warn_unary_operator_eol ( '$1' ), '$1' .
384
384
385
385
match_op_eol -> match_op : '$1' .
386
386
match_op_eol -> match_op eol : '$1' .
@@ -857,6 +857,25 @@ warn_empty_stab_clause({stab_op, {Line, _Begin, _End}, '->'}) ->
857
857
" an expression is always required on the right side of ->. "
858
858
" Please provide a value after ->" ).
859
859
860
+ warn_unary_operator_eol ({dual_op , {Line , _Begin , _End }, Op }) ->
861
+ elixir_errors :warn (Line , ? file (),
862
+ io_lib :format (
863
+ " unary operator ~ts followed by new line. "
864
+ " This may happen when you try to use a binary operator over multiple lines. "
865
+ " Please make sure that the operator and all arguments are on the same line" ,
866
+ [Op ]
867
+ )
868
+ );
869
+ warn_unary_operator_eol ({unary_op , {Line , _Begin , _End }, Op }) ->
870
+ elixir_errors :warn (Line , ? file (),
871
+ io_lib :format (
872
+ " unary operator ~ts followed by new line. "
873
+ " Please make sure the unary operator and the expression that follows "
874
+ " the operator are on the same line" ,
875
+ [Op ]
876
+ )
877
+ ).
878
+
860
879
warn_pipe ({arrow_op , {Line , _Begin , _End }, Op }, {_ , [_ | _ ], [_ | _ ]}) ->
861
880
elixir_errors :warn (Line , ? file (),
862
881
io_lib :format (
0 commit comments