Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 59c0a38

Browse files
committed
Raise if using ~r sigil in patterns or guards, closes #14767
1 parent 1be424d commit 59c0a38

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

lib/elixir/lib/kernel.ex

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6618,11 +6618,13 @@ defmodule Kernel do
66186618
defmacro sigil_r(term, modifiers)
66196619

66206620
defmacro sigil_r({:<<>>, _meta, [binary]}, options) when is_binary(binary) do
6621+
assert_no_match_or_guard_scope(__CALLER__.context, "the ~r sigil")
66216622
binary = :elixir_interpolation.unescape_string(binary, &regex_unescape_map/1)
66226623
compile_regex(binary, options)
66236624
end
66246625

66256626
defmacro sigil_r({:<<>>, meta, pieces}, options) do
6627+
assert_no_match_or_guard_scope(__CALLER__.context, "the ~r sigil")
66266628
tuple = {:<<>>, meta, unescape_tokens(pieces, &regex_unescape_map/1)}
66276629
compile_regex(tuple, options)
66286630
end

0 commit comments

Comments
 (0)