diff options
author | Glauber Campinho <ggcampinho@gmail.com> | 2018-03-25 12:37:15 +0200 |
---|---|---|
committer | José Valim <jose.valim@plataformatec.com.br> | 2018-03-27 10:47:53 +0200 |
commit | 6a0e9390a2f14efcc4774459b23d25570c019d47 (patch) | |
tree | c0321ab9e06072347a548d0a2cb5c7c960c5e365 | |
parent | d59c801f3395ec77080c8cec8980acf9d6332dc7 (diff) | |
download | elixir-6a0e9390a2f14efcc4774459b23d25570c019d47.tar.gz |
Fix column count on heredoc tokenizer (#7486)
Signed-off-by: José Valim <jose.valim@plataformatec.com.br>
-rw-r--r-- | lib/elixir/src/elixir_tokenizer.erl | 2 | ||||
-rw-r--r-- | lib/elixir/test/erlang/tokenizer_test.erl | 4 |
2 files changed, 5 insertions, 1 deletions
diff --git a/lib/elixir/src/elixir_tokenizer.erl b/lib/elixir/src/elixir_tokenizer.erl index 193c93d08..a8cda02ce 100644 --- a/lib/elixir/src/elixir_tokenizer.erl +++ b/lib/elixir/src/elixir_tokenizer.erl @@ -735,7 +735,7 @@ extract_heredoc(Line0, Column0, Rest0, Marker, Scope) -> %% in the final heredoc body three lines below. case extract_heredoc_body(Line0, Column0, Marker, [$\n | Rest1], []) of {ok, Line1, Body, Rest2, Spaces} -> - {ok, Line1, 1, tl(remove_heredoc_spaces(Body, Spaces, Marker, Scope)), Rest2}; + {ok, Line1, 4 + Spaces, tl(remove_heredoc_spaces(Body, Spaces, Marker, Scope)), Rest2}; {error, Reason, ErrorLine} -> Terminator = [Marker, Marker, Marker], {Message, Token} = heredoc_error_message(Reason, Line0, Terminator), diff --git a/lib/elixir/test/erlang/tokenizer_test.erl b/lib/elixir/test/erlang/tokenizer_test.erl index b58d0e28d..a742ab683 100644 --- a/lib/elixir/test/erlang/tokenizer_test.erl +++ b/lib/elixir/test/erlang/tokenizer_test.erl @@ -151,6 +151,10 @@ string_test() -> [{bin_string, {1, 1, nil}, [<<"f\"">>]}] = tokenize("\"f\\\"\""), [{list_string, {1, 1, nil}, [<<"foo">>]}] = tokenize("'foo'"). +heredoc_test() -> + [{bin_heredoc, {1, 1, nil}, [<<"heredoc\n">>]}] = tokenize("\"\"\"\nheredoc\n\"\"\""), + [{bin_heredoc, {1, 1, nil}, [<<"heredoc\n">>]}, {';', {3, 5, 0}}] = tokenize("\"\"\"\n heredoc\n \"\"\";"). + empty_string_test() -> [{bin_string, {1, 1, nil}, [<<>>]}] = tokenize("\"\""), [{list_string, {1, 1, nil}, [<<>>]}] = tokenize("''"). |