-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Closed
Description
Environment
$ asdf current
elixir 1.8.1-otp-21 (set by …)
erlang 21.3.6 (set by …)
Funtoo Linux current x86-64bit on intel64-ivybridge
Current behavior
Looks like that backslash (\
) character is not properly handled at end of term in sigil_S/2
. I have found it while trying sigil_S
in iex
shell, but this could affect other sigils as well.
For sure, here is current documentation of sigil_S/2
:
iex(1)> h sigil_S
defmacro sigil_S(term, modifiers)
Handles the sigil ~S for strings.
It simply returns a string without escaping characters and without
interpolations.
## Examples
iex> ~S(foo)
"foo"
iex> ~S(f#{o}o)
"f\#{o}o"
Now let's see some examples:
# 1st - only " character:
~S(") # returns: "\"" as expected
# 2nd - only \ character:
~S(\)
) # returns: ")\n" ???
# 3rd - \" characters:
~S(\") # returns: "\\\"" as expected
# 4rd - "\ characters:
~S("\)
) # returns: "\")\n" ???
# 5th - \\ characters:
~S(\\) # returns: "\\\\" as expected
I believe that current behavior is not expected and if so then we should add to documentation that \
character at end of term
needs to be escaped.
Expected behavior
Examples: 1st
, 3rd
and 5th
should not change as they are already working as expected.
# 2nd - only \ character:
~S(\) # should return: "\\"
# 4rd - "\ characters:
~S("\) # should return: "\"\\"
Metadata
Metadata
Assignees
Labels
No labels