@@ -134,7 +134,7 @@ defmodule Regex do
134134
135135 """
136136 @ spec compile ( binary , binary | [ term ] ) :: { :ok , t } | { :error , any }
137- def compile ( source , options \\ "" ) do
137+ def compile ( source , options \\ "" ) when is_binary ( source ) do
138138 compile ( source , options , version ( ) )
139139 end
140140
@@ -152,7 +152,7 @@ defmodule Regex do
152152 compile ( source , options , "" , version )
153153 end
154154
155- defp compile ( source , opts , doc_opts , version ) when is_binary ( source ) do
155+ defp compile ( source , opts , doc_opts , version ) do
156156 case :re . compile ( source , opts ) do
157157 { :ok , re_pattern } ->
158158 { :ok , % Regex { re_pattern: re_pattern , re_version: version , source: source , opts: doc_opts } }
@@ -166,7 +166,7 @@ defmodule Regex do
166166 Compiles the regular expression and raises `Regex.CompileError` in case of errors.
167167 """
168168 @ spec compile! ( binary , binary | [ term ] ) :: t
169- def compile! ( source , options \\ "" ) do
169+ def compile! ( source , options \\ "" ) when is_binary ( source ) do
170170 case compile ( source , options ) do
171171 { :ok , regex } -> regex
172172 { :error , { reason , at } } -> raise Regex.CompileError , "#{ reason } at position #{ at } "
0 commit comments