Skip to content

Commit cb15a3d

Browse files
committed
Convert line break error into a warning for v1.19
1 parent a4f98b1 commit cb15a3d

File tree

2 files changed

+8
-21
lines changed

2 files changed

+8
-21
lines changed

lib/elixir/src/elixir_interpolation.erl

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,15 @@ extract(Rest, Buffer, Output, Line, Column, Scope, Interpol, Last) ->
8989

9090
extract_char(Rest, Buffer, Output, Line, Column, Scope, Interpol, Last) ->
9191
case unicode_util:gc(Rest) of
92-
[Char | _] when ?bidi(Char); ?break(Char) ->
92+
[Char | NewRest] when ?break(Char) ->
9393
Token = io_lib:format("\\u~4.16.0B", [Char]),
94-
Pre = if
95-
?bidi(Char) -> "invalid bidirectional formatting character in string: ";
96-
true -> "invalid line break character in string: "
97-
end,
94+
Msg = io_lib:format("invalid bidirectional formatting character: ~ts. If you want to use such character, use it in its escaped ~ts form instead", [[Char], Token]),
95+
WarningScope = prepend_warning(Line, Column, Msg, Scope),
96+
extract(NewRest, [Char | Buffer], Output, Line, Column + 1, WarningScope, Interpol, Last);
97+
98+
[Char | _] when ?bidi(Char) ->
99+
Token = io_lib:format("\\u~4.16.0B", [Char]),
100+
Pre = "invalid bidirectional formatting character in string: ",
98101
Pos = io_lib:format(". If you want to use such character, use it in its escaped ~ts form instead", [Token]),
99102
{error, {?LOC(Line, Column), {Pre, Pos}, Token}};
100103

lib/elixir/test/elixir/kernel/parser_test.exs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1026,22 +1026,6 @@ defmodule Kernel.ParserTest do
10261026
["nofile:1:5:", "invalid line break character in comment: \\u2028"],
10271027
~c"foo. # This is a \u2028"
10281028
)
1029-
1030-
assert_syntax_error(
1031-
[
1032-
"nofile:1:12:",
1033-
"invalid line break character in string: \\u2028. If you want to use such character, use it in its escaped \\u2028 form instead"
1034-
],
1035-
~c"\"this is a \u2028\""
1036-
)
1037-
1038-
assert_syntax_error(
1039-
[
1040-
"nofile:1:13:",
1041-
"invalid line break character in string: \\u2028. If you want to use such character, use it in its escaped \\u2028 form instead"
1042-
],
1043-
~c"\"this is a \\\u2028\""
1044-
)
10451029
end
10461030

10471031
test "reserved tokens" do

0 commit comments

Comments
 (0)