File tree Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -62,7 +62,13 @@ defmodule Regex do
62
62
def compile ( source , options // "" )
63
63
64
64
def compile ( source , options ) when is_binary ( options ) do
65
- compile ( source , translate_options ( options ) , options )
65
+ case translate_options ( options ) do
66
+ { :error , rest } ->
67
+ { :error , { :invalid_option , rest } }
68
+
69
+ translated_options ->
70
+ compile ( source , translated_options , options )
71
+ end
66
72
end
67
73
68
74
def compile ( source , options ) when is_list ( options ) do
@@ -357,6 +363,7 @@ defmodule Regex do
357
363
defp translate_options ( << ?m , t :: binary >> ) , do: [ :multiline | translate_options ( t ) ]
358
364
defp translate_options ( << ?g , t :: binary >> ) , do: [ :groups | translate_options ( t ) ]
359
365
defp translate_options ( << >> ) , do: [ ]
366
+ defp translate_options ( rest ) , do: { :error , rest }
360
367
361
368
{ :ok , pattern } = :re . compile ( % B "\( \? <(?<G>[^>]*)>" )
362
369
@groups_pattern pattern
Original file line number Diff line number Diff line change @@ -29,6 +29,7 @@ defmodule Regex.BinaryTest do
29
29
{ :ok , regex } = Regex . compile ( "foo" )
30
30
assert is_regex ( regex )
31
31
assert { :error , _ } = Regex . compile ( "*foo" )
32
+ assert { :error , _ } = Regex . compile ( "foo" , "y" )
32
33
end
33
34
34
35
test :compile_with_erl_opts do
You can’t perform that action at this time.
0 commit comments