@@ -369,38 +369,34 @@ defmodule Module.Types.Expr do
369369 of_expr ( body , expected , body , stack , reset_warnings ( refined_context , context ) )
370370 end
371371
372- { { head_type , body_type } , _ , context } =
373- cache_arrows ( meta , stack , fn cache ? ->
374- acc = { none ( ) , none ( ) , [ ] }
372+ { { none? , body_type } , clauses_acc , context } =
373+ cache_arrows ( meta , stack , fn _cache ? ->
374+ acc = { false , none ( ) , [ ] }
375375
376376 { { head_acc , body_acc , clauses_acc } , context } =
377377 of_clauses_fun ( clauses , [ case_type ] , info , stack , context , of_body , acc , fn
378- trees , precise? , body_type , context , { head_acc , body_acc , clauses_acc } ->
379- cond do
380- precise? and empty? ( body_type ) ->
381- [ arg_type ] = Pattern . of_domain ( trees , stack , context )
382- { union ( negation ( arg_type ) , head_acc ) , body_acc , clauses_acc }
383-
384- cache? ->
385- [ arg_type ] = Pattern . of_domain ( trees , stack , context )
386- { head_acc , union ( body_type , body_acc ) , [ { arg_type , body_type } | clauses_acc ] }
387-
388- true ->
389- { head_acc , union ( body_type , body_acc ) , clauses_acc }
378+ trees , precise? , body_type , context , { none? , body_acc , clauses_acc } ->
379+ if precise? and empty? ( body_type ) do
380+ { true , body_acc , clauses_acc }
381+ else
382+ [ arg_type ] = Pattern . of_domain ( trees , stack , context )
383+ { none? , union ( body_type , body_acc ) , [ { arg_type , body_type } | clauses_acc ] }
390384 end
391385 end )
392386
393387 { { head_acc , body_acc } , clauses_acc , context }
394388 end )
395389
396390 context =
397- if head_type == none ( ) do
398- context
399- else
391+ if none? do
392+ head_type = Enum . reduce ( clauses_acc , none ( ) , & union ( elem ( & 1 , 0 ) , & 2 ) )
393+
400394 { _ , refined_context } =
401395 of_expr ( case_expr , head_type , case_expr , % { stack | reverse_arrow: :use } , context )
402396
403397 reset_warnings ( refined_context , context )
398+ else
399+ context
404400 end
405401
406402 dynamic_unless_static ( { body_type , context } , stack )
0 commit comments