Skip to content

Commit 4ade0f9

Browse files
author
José Valim
committed
Remove deprecated code
1 parent 67a672e commit 4ade0f9

File tree

7 files changed

+35
-104
lines changed

7 files changed

+35
-104
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* Enhancements
1414
* [EEx] Allow `EEx.AssignsEngine` to accept any Dict
1515
* [Enum] Add `Enum.flat_map_reduce/3`
16-
* [ExUnit] Support @moduletag in ExUnit cases
16+
* [ExUnit] Support `@moduletag` in ExUnit cases
1717
* [Kernel] Improve stacktraces to be relative to the compilation path and include the related application
1818
* [Stream] Add `Stream.transform/3`
1919

lib/elixir/lib/enum.ex

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -741,20 +741,6 @@ defmodule Enum do
741741
end
742742
end
743743

744-
@doc false
745-
@spec first(t) :: :nil | element
746-
def first(list) when is_list(list) do
747-
IO.write "Enum.first/1 is deprecated, please use Enum.at/2 or List.first/1 instead\n#{Exception.format_stacktrace}"
748-
List.first(list)
749-
end
750-
751-
def first(collection) do
752-
IO.write "Enum.first/1 is deprecated, please use Enum.at/2 instead\n#{Exception.format_stacktrace}"
753-
Enumerable.reduce(collection, { :cont, nil }, fn(entry, _) ->
754-
{ :halt, entry }
755-
end) |> elem(1)
756-
end
757-
758744
@doc """
759745
Returns a new collection appending the result of invoking `fun`
760746
on each corresponding item of `collection`.

lib/elixir/lib/kernel.ex

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -506,13 +506,6 @@ defmodule Kernel do
506506
:erlang.iolist_to_binary(item)
507507
end
508508

509-
@doc false
510-
@spec is_alive :: boolean
511-
def is_alive do
512-
IO.write "is_alive/0 is deprecated, please use Node.alive?/0 instead\n#{Exception.format_stacktrace}"
513-
:erlang.is_alive
514-
end
515-
516509
@doc """
517510
Returns `true` if `term` is an atom; otherwise returns `false`.
518511
@@ -1136,12 +1129,6 @@ defmodule Kernel do
11361129
quote do: __op__(:/, unquote(left), unquote(right))
11371130
end
11381131

1139-
@doc false
1140-
def pid <- msg do
1141-
IO.write "<-/2 is deprecated, please use send/2 instead\n#{Exception.format_stacktrace}"
1142-
:erlang.!(pid, msg)
1143-
end
1144-
11451132
@doc """
11461133
Concatenates two lists. Allowed in guard clauses.
11471134
@@ -1774,22 +1761,7 @@ defmodule Kernel do
17741761
17751762
"""
17761763
@spec inspect(Inspect.t, Keyword.t) :: String.t
1777-
def inspect(arg, opts // [])
1778-
1779-
def inspect(arg, opts) when is_tuple(opts) and tuple_size(opts) > 0 and elem(opts, 0) == Inspect.Opts do
1780-
IO.write "Kernel.inspect/2 with Inspect.Opts is deprecated, please use Inspect.Algebra.to_doc/2 instead\n#{Exception.format_stacktrace}"
1781-
Inspect.Algebra.to_doc(arg, opts)
1782-
end
1783-
1784-
def inspect(arg, opts) when is_list(opts) do
1785-
case Keyword.get(opts, :raw) do
1786-
nil ->
1787-
:ok
1788-
raw ->
1789-
IO.write "Kernel.inspect/2 with :raw option is deprecated, please use :records instead\n#{Exception.format_stacktrace}"
1790-
opts = opts ++ [records: not raw]
1791-
end
1792-
1764+
def inspect(arg, opts // []) when is_list(opts) do
17931765
opts = Inspect.Opts.new(opts)
17941766
limit = case opts.pretty do
17951767
true -> opts.width

lib/elixir/lib/macro.ex

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -641,12 +641,6 @@ defmodule Macro do
641641
do: { env.module, true }
642642
defp do_expand_once({ :__DIR__, _, atom }, env) when is_atom(atom),
643643
do: { :filename.dirname(env.file), true }
644-
645-
defp do_expand_once({ :__FILE__, _, atom }, env) when is_atom(atom) do
646-
IO.write "__FILE__ is deprecated, please use __DIR__ or __ENV__.file instead\n#{Exception.format_stacktrace}"
647-
{ env.file, true }
648-
end
649-
650644
defp do_expand_once({ :__ENV__, _, atom }, env) when is_atom(atom),
651645
do: { { :{}, [], tuple_to_list(env) }, true }
652646
defp do_expand_once({ { :., _, [{ :__ENV__, _, atom }, field] }, _, [] } = original, env) when

lib/elixir/src/elixir_exp.erl

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,6 @@ expand({ import, Meta, [Ref, KV] }, E) ->
122122

123123
expand({ '__MODULE__', _, Atom }, E) when is_atom(Atom) ->
124124
{ E#elixir_env.module, E };
125-
expand({ '__FILE__', Meta, Atom }, E) when is_atom(Atom) ->
126-
elixir_errors:deprecation(Meta, E#elixir_env.file, "__FILE__ is deprecated, please use __DIR__ or __ENV__.file instead"),
127-
{ E#elixir_env.file, E };
128125
expand({ '__DIR__', _, Atom }, E) when is_atom(Atom) ->
129126
{ filename:dirname(E#elixir_env.file), E };
130127
expand({ '__CALLER__', _, Atom } = Caller, E) when is_atom(Atom) ->

lib/elixir/src/elixir_tokenizer.erl

Lines changed: 27 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,11 @@ tokenize([$#|String], Line, Scope, Tokens) ->
141141

142142
tokenize([$%,S,H,H,H|T] = Original, Line, Scope, Tokens) when ?is_quote(H), ?is_upcase(S) orelse ?is_downcase(S) ->
143143
case extract_heredoc_with_interpolation(Line, Scope, ?is_downcase(S), T, H) of
144-
{ error, Reason } ->
145-
{ error, Reason, Original, Tokens };
146-
{ Parts, Rest } ->
144+
{ ok, NewLine, Parts, Rest } ->
147145
{ Final, Modifiers } = collect_modifiers(Rest, []),
148-
tokenize(Final, Line, Scope, [{ sigil, Line, S, Parts, Modifiers }|Tokens])
146+
tokenize(Final, NewLine, Scope, [{ sigil, Line, S, Parts, Modifiers }|Tokens]);
147+
{ error, Reason } ->
148+
{ error, Reason, Original, Tokens }
149149
end;
150150

151151
tokenize([$%,S,H|T] = Original, Line, Scope, Tokens) when not(?is_identifier(H)), not(?is_terminator(H)), ?is_upcase(S) orelse ?is_downcase(S) ->
@@ -482,11 +482,6 @@ tokenize([Space, Sign, NotMarker|T], Line, Scope, [{ Identifier, _, _ } = H|Toke
482482

483483
tokenize([T|Rest], Line, Scope, Tokens) when ?is_horizontal_space(T) ->
484484
tokenize(Rest, Line, Scope, Tokens);
485-
486-
%% TODO: This token is deprecated once continuable heredocs are removed
487-
tokenize([{line,Line}|Rest], _Line, Scope, Tokens) ->
488-
tokenize(Rest, Line, Scope, Tokens);
489-
490485
tokenize(T, Line, _Scope, Tokens) ->
491486
{ error, { Line, "invalid token: ", until_eol(T) }, T, Tokens }.
492487

@@ -503,11 +498,11 @@ escape_char(List) ->
503498

504499
handle_heredocs(T, Line, H, Scope, Tokens) ->
505500
case extract_heredoc_with_interpolation(Line, Scope, true, T, H) of
506-
{ error, Reason } ->
507-
{ error, Reason, [H, H, H] ++ T, Tokens };
508-
{ Parts, Rest } ->
501+
{ ok, NewLine, Parts, Rest } ->
509502
Token = { string_type(H), Line, unescape_tokens(Parts) },
510-
tokenize(Rest, Line, Scope, [Token|Tokens])
503+
tokenize(Rest, NewLine, Scope, [Token|Tokens]);
504+
{ error, Reason } ->
505+
{ error, Reason, [H, H, H] ++ T, Tokens }
511506
end.
512507

513508
handle_strings(T, Line, H, Scope, Tokens) ->
@@ -575,34 +570,33 @@ collect_modifiers(Rest, Buffer) ->
575570
%% Heredocs
576571

577572
extract_heredoc_with_interpolation(Line, Scope, Interpol, T, H) ->
578-
case extract_heredoc(Line, T, H, Scope) of
579-
{ error, _ } = Error ->
580-
Error;
581-
{ Body, Rest } ->
573+
case extract_heredoc(Line, T, H) of
574+
{ ok, NewLine, Body, Rest } ->
582575
case elixir_interpolation:extract(Line + 1, Scope, Interpol, Body, 0) of
583576
{ error, Reason } ->
584577
{ error, interpolation_format(Reason, " (for heredoc starting at line ~B)", [Line]) };
585578
{ _, Parts, [] } ->
586-
{ Parts, Rest }
587-
end
579+
{ ok, NewLine, Parts, Rest }
580+
end;
581+
{ error, _ } = Error ->
582+
Error
588583
end.
589584

590-
extract_heredoc(Line0, Rest0, Marker, Scope) ->
591-
case extract_heredoc_header(Rest0, [], {Line0,Scope#elixir_tokenizer.file}) of
592-
{ ok, Extra, Rest1 } ->
585+
extract_heredoc(Line0, Rest0, Marker) ->
586+
case extract_heredoc_header(Rest0) of
587+
{ ok, Rest1 } ->
593588
%% We prepend a new line so we can transparently remove
594589
%% spaces later. This new line is removed by calling `tl`
595590
%% in the final heredoc body three lines below.
596591
case extract_heredoc_body(Line0, Marker, [$\n|Rest1], []) of
597-
{ Line1, Body, Rest2, Spaces } ->
598-
{ tl(remove_heredoc_spaces(Body, Spaces)), merge_heredoc_extra(Line1, Extra, Rest2) };
592+
{ ok, Line1, Body, Rest2, Spaces } ->
593+
{ ok, Line1, tl(remove_heredoc_spaces(Body, Spaces)), Rest2 };
599594
{ error, ErrorLine } ->
600595
Terminator = [Marker, Marker, Marker],
601596
Message = "missing terminator: ~ts (for heredoc starting at line ~B)",
602597
{ error, { ErrorLine, io_lib:format(Message, [Terminator, Line0]), [] } }
603598
end;
604599
error ->
605-
%% TODO: Test me once the deprecated continuable heredocs are removed
606600
Terminator = [Marker, Marker, Marker],
607601
Message = "heredoc start ~ts must be followed by a new line",
608602
{ error, { Line0, io_lib:format(Message, [Terminator]), [] } }
@@ -625,32 +619,25 @@ remove_heredoc_spaces([], Buffer, _Spaces, _Original) ->
625619

626620
%% Extract the heredoc header.
627621

628-
extract_heredoc_header("\r\n" ++ Rest, Buffer, _Scope) ->
629-
{ ok, Buffer, Rest };
630-
extract_heredoc_header("\n" ++ Rest, Buffer, _Scope) ->
631-
{ ok, Buffer, Rest };
632-
extract_heredoc_header([H|T], Buffer, {Line,File}) when not ?is_horizontal_space(H) ->
633-
elixir_errors:deprecation([{line,Line}], File, "continuable heredocs are deprecated, parsing will no longer continue on the same line as the heredoc starts"),
634-
extract_heredoc_header(T, [H|Buffer], nil);
635-
extract_heredoc_header([H|T], Buffer, _Scope) ->
636-
extract_heredoc_header(T, [H|Buffer], _Scope);
637-
extract_heredoc_header(_, _, _Scope) ->
622+
extract_heredoc_header("\r\n" ++ Rest) ->
623+
{ ok, Rest };
624+
extract_heredoc_header("\n" ++ Rest) ->
625+
{ ok, Rest };
626+
extract_heredoc_header([_|T]) ->
627+
extract_heredoc_header(T);
628+
extract_heredoc_header(_) ->
638629
error.
639630

640631
%% Extract heredoc body. It returns the heredoc body (in reverse order),
641632
%% the remaining of the document and the number of spaces the heredoc
642633
%% is aligned.
643634

644-
%% TODO: This token is deprecated once continuable heredocs are removed
645-
extract_heredoc_body(_Line, Marker, [{line,NewLine}|Rest], Buffer) ->
646-
extract_heredoc_body(NewLine, Marker, Rest, Buffer);
647-
648635
extract_heredoc_body(Line, Marker, Rest, Buffer) ->
649636
case extract_heredoc_line(Marker, Rest, Buffer, 0) of
650637
{ ok, NewBuffer, NewRest } ->
651638
extract_heredoc_body(Line + 1, Marker, NewRest, NewBuffer);
652639
{ ok, NewBuffer, NewRest, Spaces } ->
653-
{ Line, NewBuffer, NewRest, Spaces };
640+
{ ok, Line, NewBuffer, NewRest, Spaces };
654641
{ error, eof } ->
655642
{ error, Line }
656643
end.
@@ -675,17 +662,6 @@ extract_heredoc_line(Marker, [Marker,Marker,Marker|T], Buffer, Counter) ->
675662
extract_heredoc_line(_Marker, Rest, Buffer, _Counter) ->
676663
extract_heredoc_line(Rest, Buffer).
677664

678-
%% Merge heredoc extra by replying it on the buffer. It also adds
679-
%% a special { line, Line } token to force a line change along the way.
680-
681-
%% TODO: This token is deprecated once continuable heredocs are removed
682-
merge_heredoc_extra(Line, Extra, Buffer) ->
683-
merge_heredoc_extra(Extra, [{line,Line}|Buffer]).
684-
merge_heredoc_extra([H|T], Buffer) ->
685-
merge_heredoc_extra(T, [H|Buffer]);
686-
merge_heredoc_extra([], Buffer) ->
687-
Buffer.
688-
689665
%% Integers and floats
690666
%% At this point, we are at least sure the first digit is a number.
691667

lib/elixir/test/elixir/kernel/errors_test.exs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@ defmodule Kernel.ErrorsTest do
4949
'"bar'
5050
end
5151

52+
test :heredoc_start do
53+
assert_compile_fail TokenMissingError,
54+
"nofile:1: heredoc start \"\"\" must be followed by a new line",
55+
'"""bar'
56+
end
57+
5258
test :heredoc_terminator do
5359
assert_compile_fail TokenMissingError,
5460
"nofile:2: missing terminator: \"\"\" (for heredoc starting at line 1)",

0 commit comments

Comments
 (0)