Only rearrange not in if explicitly opted-in

Closes #7227.
This commit is contained in:
José Valim
2018-01-19 10:54:39 +01:00
parent 582e8210da
commit bfa3cfba19
3 changed files with 21 additions and 5 deletions
+8 -2
View File
@@ -684,13 +684,19 @@ number_value({_, {_, _, Value}, _}) ->
%% Operators
build_op({_Kind, Location, 'in'}, {UOp, _, [Left]}, Right) when ?rearrange_uop(UOp) ->
%% TODO: Raise on "not left in right" rearrangement on 2.0
%% TODO: Remove "not left in right" rearrangement on 2.0
elixir_errors:warn(line_from_location(Location), ?file(),
"\"not expr1 in expr2\" is deprecated. Use \"expr1 not in expr2\" instead"),
{UOp, meta_from_location(Location), [{'in', meta_from_location(Location), [Left, Right]}]};
build_op({_Kind, Location, 'not in'}, Left, Right) ->
{'not', meta_from_location(Location), [{'in', meta_from_location(Location), [Left, Right]}]};
InMeta = meta_from_location(Location),
NotMeta =
case ?formatter_metadata() of
true -> [{operator, 'not in'} | InMeta];
false -> InMeta
end,
{'not', NotMeta, [{'in', InMeta, [Left, Right]}]};
build_op({_Kind, Location, Op}, Left, Right) ->
{Op, eol_op(Location) ++ meta_from_location(Location), [Left, Right]}.