Skip to content

Commit 51d23cb

Browse files
committed
Do not escape \ in uppercase sigils, closes #8989
1 parent dbde3ba commit 51d23cb

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

lib/elixir/src/elixir_interpolation.erl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ extract([$#, ${ | Rest], Buffer, Output, Line, Column, Scope, true, Last) ->
6060
{error, {string, Line, Column, "missing interpolation terminator: \"}\"", []}}
6161
end;
6262

63-
extract([$\\ | Rest], Buffer, Output, Line, Column, Scope, Interpol, Last) ->
64-
extract_char(Rest, [$\\ | Buffer], Output, Line, Column + 1, Scope, Interpol, Last);
63+
extract([$\\ | Rest], Buffer, Output, Line, Column, Scope, true, Last) ->
64+
extract_char(Rest, [$\\ | Buffer], Output, Line, Column + 1, Scope, true, Last);
6565

6666
%% Catch all clause
6767

lib/elixir/test/elixir/code_formatter/literals_test.exs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ defmodule Code.Formatter.LiteralsTest do
8585
end
8686

8787
test "without escapes" do
88-
assert_same ~S[:foo]
89-
assert_same ~S[:\\]
88+
assert_same ~s[:foo]
89+
assert_same ~s[:\\\\]
9090
end
9191

9292
test "with escapes" do

lib/elixir/test/elixir/kernel/sigils_test.exs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ defmodule Kernel.SigilsTest do
2929
assert ~S(f\no) == "f\\no"
3030
assert ~S(foo\)) == "foo)"
3131
assert ~S[foo\]] == "foo]"
32+
assert ~S[foo\\]] == "foo\\]"
3233
end
3334

3435
test "sigil S newline" do

0 commit comments

Comments
 (0)