@@ -378,9 +378,9 @@ capture_op_eol -> capture_op : '$1'.
378378capture_op_eol -> capture_op eol : '$1' .
379379
380380unary_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' .
382382unary_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' .
384384
385385match_op_eol -> match_op : '$1' .
386386match_op_eol -> match_op eol : '$1' .
@@ -857,6 +857,25 @@ warn_empty_stab_clause({stab_op, {Line, _Begin, _End}, '->'}) ->
857857 " an expression is always required on the right side of ->. "
858858 " Please provide a value after ->" ).
859859
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+
860879warn_pipe ({arrow_op , {Line , _Begin , _End }, Op }, {_ , [_ | _ ], [_ | _ ]}) ->
861880 elixir_errors :warn (Line , ? file (),
862881 io_lib :format (
0 commit comments