@@ -76,7 +76,7 @@ defmodule Module.Types.Expr do
76
76
do: { empty_list ( ) , context }
77
77
78
78
# [expr, ...]
79
- # TODO : here
79
+ # PENDING : here
80
80
def of_expr ( list , _expected , expr , stack , context ) when is_list ( list ) do
81
81
{ prefix , suffix } = unpack_list ( list , [ ] )
82
82
{ prefix , context } = Enum . map_reduce ( prefix , context , & of_expr ( & 1 , @ pending , expr , stack , & 2 ) )
@@ -90,7 +90,7 @@ defmodule Module.Types.Expr do
90
90
end
91
91
92
92
# {left, right}
93
- # TODO : here
93
+ # PENDING : here
94
94
def of_expr ( { left , right } , _expected , expr , stack , context ) do
95
95
{ left , context } = of_expr ( left , @ pending , expr , stack , context )
96
96
{ right , context } = of_expr ( right , @ pending , expr , stack , context )
@@ -103,7 +103,7 @@ defmodule Module.Types.Expr do
103
103
end
104
104
105
105
# {...}
106
- # TODO : here
106
+ # PENDING : here
107
107
def of_expr ( { :{} , _meta , exprs } , _expected , expr , stack , context ) do
108
108
{ types , context } = Enum . map_reduce ( exprs , context , & of_expr ( & 1 , @ pending , expr , stack , & 2 ) )
109
109
@@ -153,7 +153,7 @@ defmodule Module.Types.Expr do
153
153
154
154
# %{map | ...}
155
155
# TODO: Once we support typed structs, we need to type check them here.
156
- # TODO : here
156
+ # PENDING : here
157
157
def of_expr ( { :%{} , meta , [ { :| , _ , [ map , args ] } ] } = expr , _expected , _expr , stack , context ) do
158
158
{ map_type , context } = of_expr ( map , @ pending , expr , stack , context )
159
159
@@ -195,7 +195,7 @@ defmodule Module.Types.Expr do
195
195
# Note this code, by definition, adds missing struct fields to `map`
196
196
# because at runtime we do not check for them (only for __struct__ itself).
197
197
# TODO: Once we support typed structs, we need to type check them here.
198
- # TODO : here
198
+ # PENDING : here
199
199
def of_expr (
200
200
{ :% , struct_meta , [ module , { :%{} , _ , [ { :| , update_meta , [ map , args ] } ] } ] } = expr ,
201
201
_expected ,
@@ -222,13 +222,13 @@ defmodule Module.Types.Expr do
222
222
end
223
223
224
224
# %{...}
225
- # TODO : here
225
+ # PENDING : here
226
226
def of_expr ( { :%{} , _meta , args } , _expected , expr , stack , context ) do
227
227
Of . closed_map ( args , stack , context , & of_expr ( & 1 , @ pending , expr , & 2 , & 3 ) )
228
228
end
229
229
230
230
# %Struct{}
231
- # TODO : here
231
+ # PENDING : here
232
232
def of_expr ( { :% , meta , [ module , { :%{} , _ , args } ] } , _expected , expr , stack , context ) do
233
233
Of . struct_instance ( module , args , meta , stack , context , & of_expr ( & 1 , @ pending , expr , & 2 , & 3 ) )
234
234
end
@@ -281,9 +281,9 @@ defmodule Module.Types.Expr do
281
281
|> dynamic_unless_static ( stack )
282
282
end
283
283
284
- # TODO: here
285
284
def of_expr ( { :case , meta , [ case_expr , [ { :do , clauses } ] ] } , expected , expr , stack , context ) do
286
285
{ case_type , context } = of_expr ( case_expr , @ pending , case_expr , stack , context )
286
+ info = { :case , meta , case_type , case_expr }
287
287
288
288
# If we are only type checking the expression and the expression is a literal,
289
289
# let's mark it as generated, as it is most likely a macro code. However, if
@@ -293,14 +293,7 @@ defmodule Module.Types.Expr do
293
293
else
294
294
clauses
295
295
end
296
- |> of_clauses (
297
- [ case_type ] ,
298
- expected ,
299
- expr ,
300
- { :case , meta , case_type , case_expr } ,
301
- stack ,
302
- { none ( ) , context }
303
- )
296
+ |> of_clauses ( [ case_type ] , expected , expr , info , stack , { none ( ) , context } )
304
297
|> dynamic_unless_static ( stack )
305
298
end
306
299
@@ -313,24 +306,15 @@ defmodule Module.Types.Expr do
313
306
{ fun ( ) , context }
314
307
end
315
308
316
- # TODO: here
317
309
def of_expr ( { :try , _meta , [ [ do: body ] ++ blocks ] } , expected , expr , stack , original ) do
318
310
{ after_block , blocks } = Keyword . pop ( blocks , :after )
319
311
{ else_block , blocks } = Keyword . pop ( blocks , :else )
320
312
321
313
{ type , context } =
322
314
if else_block do
323
315
{ type , context } = of_expr ( body , @ pending , body , stack , original )
324
-
325
- of_clauses (
326
- else_block ,
327
- [ type ] ,
328
- expected ,
329
- expr ,
330
- { :try_else , type } ,
331
- stack ,
332
- { none ( ) , context }
333
- )
316
+ info = { :try_else , type }
317
+ of_clauses ( else_block , [ type ] , expected , expr , info , stack , { none ( ) , context } )
334
318
else
335
319
of_expr ( body , expected , expr , stack , original )
336
320
end
@@ -373,7 +357,6 @@ defmodule Module.Types.Expr do
373
357
374
358
@ timeout_type union ( integer ( ) , atom ( [ :infinity ] ) )
375
359
376
- # TODO: here
377
360
def of_expr ( { :receive , _meta , [ blocks ] } , expected , expr , stack , original ) do
378
361
blocks
379
362
|> Enum . reduce ( { none ( ) , original } , fn
0 commit comments