@@ -156,7 +156,7 @@ defmodule Module.Types.Expr do
156
156
{ :ok , map_type , context } <- of_expr ( map , stack , context ) do
157
157
if disjoint? ( struct_type , map_type ) do
158
158
warning = { :badupdate , :struct , expr , struct_type , map_type , context }
159
- { :ok , dynamic ( ) , warn ( __MODULE__ , warning , update_meta , stack , context ) }
159
+ { :ok , error_type ( ) , warn ( __MODULE__ , warning , update_meta , stack , context ) }
160
160
else
161
161
# TODO: Merge args_type into map_type with dynamic/static key requirement
162
162
Of . struct ( module , args_types , :merge_defaults , struct_meta , stack , context )
@@ -384,12 +384,10 @@ defmodule Module.Types.Expr do
384
384
if Code . ensure_loaded? ( exception ) and function_exported? ( exception , :__struct__ , 0 ) do
385
385
Of . struct ( exception , args , :merge_defaults , meta , stack , context )
386
386
else
387
- # Whenever there is a failure (such as undefined function),
388
- # we return dynamic to avoid cascading errors. In this case,
389
- # we can return something a bit more precise than dynamic,
390
- # but we still want an open map to avoid cascading.
387
+ # If the exception cannot be found or is invalid,
388
+ # we call Of.remote/5 to emit a warning.
391
389
context = Of . remote ( exception , :__struct__ , 0 , meta , stack , context )
392
- { :ok , dynamic ( open_map ( [ __struct__: atom ( [ exception ] ) ] ++ args ) ) , context }
390
+ { :ok , error_type ( ) , context }
393
391
end
394
392
end ) do
395
393
context =
@@ -480,6 +478,8 @@ defmodule Module.Types.Expr do
480
478
481
479
## General helpers
482
480
481
+ defp error_type ( ) , do: dynamic ( )
482
+
483
483
defp apply_many ( [ ] , _function , _args_types , _expr , _stack , context ) do
484
484
{ :ok , dynamic ( ) , context }
485
485
end
0 commit comments