Kin
October 13, 2023, 8:45am
1
I am following the elixir official docs and on the sigil page here Sigils - The Elixir programming language
this example:
sigil_r(<<"foo">>, ~c"i")
is not working for me. The output should be
~r"foo"i
but it is:
iex(48)> sigil_r(<<"foo">>, ~c"i")
** (ArgumentError) errors were found at the given arguments:
* 1st argument: not an iodata term
(stdlib 5.0.2) :binary.list_to_bin({:sigil_c, [delimiter: "\"", line: 48], [{:<<>>, [line: 48], ["i"]}, []]})
(elixir 1.15.5) expanding macro: Kernel.sigil_r/2
iex:48: (file)
1 Like
Nicd
October 13, 2023, 9:22am
2
Looks like it works with the old charlist syntax but not with the new:
iex(1)> sigil_r(<<"foo">>, 'i')
~r/foo/i
iex(2)> sigil_r(<<"foo">>, ~c"i")
** (ArgumentError) errors were found at the given arguments:
* 1st argument: not an iodata term
(stdlib 5.1.1) :binary.list_to_bin({:sigil_c, [delimiter: "\"", line: 2], [{:<<>>, [line: 2], ["i"]}, []]})
(elixir 1.15.6) expanding macro: Kernel.sigil_r/2
iex:2: (file)
I guess the syntax has been changed to the new one without checking if it works. Filing an issue here could be a good starting point: GitHub - elixir-lang/elixir-lang.github.com: Website for Elixir
2 Likes
You are right, it should be:
sigil_r(<<"foo">>, [?i])
Would you like to submit a PR to the docs or shall I update it?
4 Likes
Kin
October 13, 2023, 9:50am
4
Please, do it if you can.