Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions lib/elixir/src/elixir_interpolation.erl
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,15 @@ extract([$\\ | Rest], Buffer, Output, Line, Column, Scope, Interpol, Last) ->

%% Catch all clause

extract([Char | _Rest], _Buffer, _Output, Line, Column, _Scope, _Interpol, _Last)
when ?break(Char) ->
Token = io_lib:format("\\u~4.16.0B", [Char]),
Pos = io_lib:format(". If you want to use such character, use it in its escaped ~ts form instead", [Token]),
{error, {?LOC(Line, Column),
{"invalid line break character in string: ",
Pos},
Token}};

extract([Char1, Char2 | Rest], Buffer, Output, Line, Column, Scope, Interpol, Last)
when Char1 =< 255, Char2 =< 255 ->
extract([Char2 | Rest], [Char1 | Buffer], Output, Line, Column + 1, Scope, Interpol, Last);
Expand Down
24 changes: 24 additions & 0 deletions lib/elixir/test/elixir/kernel/parser_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -1131,6 +1131,30 @@ defmodule Kernel.ParserTest do
],
~c"\"this is a \\\u2028\""
)

assert_syntax_error(
[
"nofile:1:12:",
"invalid line break character in string: \\u000B. If you want to use such character, use it in its escaped \\u000B form instead"
],
:erlang.list_to_binary([34] ++ ~c"this is a " ++ [11, 34])
)

assert_syntax_error(
[
"nofile:1:12:",
"invalid line break character in string: \\u000C. If you want to use such character, use it in its escaped \\u000C form instead"
],
:erlang.list_to_binary([34] ++ ~c"this is a " ++ [12, 34])
)

assert_syntax_error(
[
"nofile:1:12:",
"invalid line break character in string: \\u0085. If you want to use such character, use it in its escaped \\u0085 form instead"
],
<<34, "this is a ", 194, 133, 34>>
)
end

test "reserved tokens" do
Expand Down
Loading