@@ -63,15 +63,15 @@ defmodule Module.Types.Pattern do
6363
6464 { :error , _old_type , error_context } ->
6565 if match_error? ( var , new_type ) do
66- throw ( badmatch_error ( var , expr , stack , context ) )
66+ throw ( badpattern_error ( var , expr , stack , context ) )
6767 else
6868 throw ( badvar_error ( var , old_type , new_type , stack , error_context ) )
6969 end
7070 end
7171 end
7272
7373 :error ->
74- throw ( badmatch_error ( var , expr , stack , context ) )
74+ throw ( badpattern_error ( var , expr , stack , context ) )
7575 end
7676 end )
7777 catch
@@ -260,9 +260,9 @@ defmodule Module.Types.Pattern do
260260 error ( __MODULE__ , error , error_meta ( var , stack ) , stack , context )
261261 end
262262
263- defp badmatch_error ( var , expr , stack , context ) do
263+ defp badpattern_error ( var , expr , stack , context ) do
264264 context = Of . error_var ( var , context )
265- error ( __MODULE__ , { :badmatch , expr , context } , error_meta ( expr , stack ) , stack , context )
265+ error ( __MODULE__ , { :badpattern , expr , context } , error_meta ( expr , stack ) , stack , context )
266266 end
267267
268268 defp badpattern_error ( expr , index , tag , stack , context ) do
@@ -272,7 +272,7 @@ defmodule Module.Types.Pattern do
272272 if index do
273273 { :badpattern , meta , expr , index , tag , context }
274274 else
275- { :badmatch , expr , context }
275+ { :badpattern , expr , context }
276276 end
277277
278278 error ( __MODULE__ , error , meta , stack , context )
@@ -1012,15 +1012,15 @@ defmodule Module.Types.Pattern do
10121012 }
10131013 end
10141014
1015- def format_diagnostic ( { :badmatch , expr , context } ) do
1015+ def format_diagnostic ( { :badpattern , expr , context } ) do
10161016 traces = collect_traces ( expr , context )
10171017
10181018 % {
10191019 details: % { typing_traces: traces } ,
10201020 message:
10211021 IO . iodata_to_binary ( [
10221022 """
1023- this match will never succeed due to incompatible types :
1023+ the following pattern will never match :
10241024
10251025 #{ expr_to_string ( expr ) |> indent ( 4 ) }
10261026 """ ,
@@ -1146,7 +1146,7 @@ defmodule Module.Types.Pattern do
11461146 """ }
11471147 end
11481148
1149- defp badpattern ( { :infer , types } , pattern_or_expr , index ) do
1149+ defp badpattern ( { :infer , types } , pattern_or_expr , index ) when is_integer ( index ) do
11501150 type = Enum . fetch! ( types , index )
11511151
11521152 if type == dynamic ( ) do
0 commit comments