@@ -135,8 +135,7 @@ defmodule Module.Types do
135
135
# Collect relevant information from context and traces to report error
136
136
def error_to_warning ( :unable_apply , { mfa , args , expected , signature , stack } , context ) do
137
137
{ 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 } }
140
139
141
140
traces = type_traces ( stack , context )
142
141
{ [ signature | args ] , traces } = lift_all_types ( [ signature | args ] , traces , context )
@@ -146,15 +145,16 @@ defmodule Module.Types do
146
145
147
146
def error_to_warning ( :unable_unify , { left , right , stack } , context ) do
148
147
{ 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 } }
151
149
152
150
traces = type_traces ( stack , context )
153
151
{ [ left , right ] , traces } = lift_all_types ( [ left , right ] , traces , context )
154
152
error = { :unable_unify , left , right , { location , stack . last_expr , traces } }
155
153
{ Module.Types , error , location }
156
154
end
157
155
156
+ defp get_line ( stack ) , do: stack . last_expr |> get_meta ( ) |> Keyword . get ( :line , 0 )
157
+
158
158
# Collect relevant traces from context.traces using stack.unify_stack
159
159
defp type_traces ( stack , context ) do
160
160
# TODO: Do we need the unify_stack or is enough to only get the last variable
0 commit comments