@@ -135,8 +135,7 @@ defmodule Module.Types do
135135 # Collect relevant information from context and traces to report error
136136 def error_to_warning ( :unable_apply , { mfa , args , expected , signature , stack } , context ) do
137137 { fun , arity } = context . function
138- line = get_meta ( stack . last_expr ) [ :line ]
139- location = { context . file , line , { context . module , fun , arity } }
138+ location = { context . file , get_line ( stack ) , { context . module , fun , arity } }
140139
141140 traces = type_traces ( stack , context )
142141 { [ signature | args ] , traces } = lift_all_types ( [ signature | args ] , traces , context )
@@ -146,15 +145,16 @@ defmodule Module.Types do
146145
147146 def error_to_warning ( :unable_unify , { left , right , stack } , context ) do
148147 { fun , arity } = context . function
149- line = get_meta ( stack . last_expr ) [ :line ]
150- location = { context . file , line , { context . module , fun , arity } }
148+ location = { context . file , get_line ( stack ) , { context . module , fun , arity } }
151149
152150 traces = type_traces ( stack , context )
153151 { [ left , right ] , traces } = lift_all_types ( [ left , right ] , traces , context )
154152 error = { :unable_unify , left , right , { location , stack . last_expr , traces } }
155153 { Module.Types , error , location }
156154 end
157155
156+ defp get_line ( stack ) , do: stack . last_expr |> get_meta ( ) |> Keyword . get ( :line , 0 )
157+
158158 # Collect relevant traces from context.traces using stack.unify_stack
159159 defp type_traces ( stack , context ) do
160160 # TODO: Do we need the unify_stack or is enough to only get the last variable
0 commit comments