@@ -1103,26 +1103,26 @@ defmodule Module.Types.DescrTest do
11031103
11041104 test "static" do
11051105 # Full static
1106- assert fun_apply ( fun ( ) , [ integer ( ) ] ) == { :badarg , [ none ( ) ] }
1107- assert fun_apply ( difference ( fun ( ) , none_fun ( 2 ) ) , [ integer ( ) ] ) == { :badarg , [ none ( ) ] }
1106+ assert fun_apply ( fun ( ) , [ integer ( ) ] ) == { :badarg , [ none ( ) ] , false }
1107+ assert fun_apply ( difference ( fun ( ) , none_fun ( 2 ) ) , [ integer ( ) ] ) == { :badarg , [ none ( ) ] , false }
11081108
11091109 # Basic function application scenarios
11101110 assert fun_apply ( fun ( [ integer ( ) ] , atom ( ) ) , [ integer ( ) ] ) == { :ok , atom ( ) }
1111- assert fun_apply ( fun ( [ integer ( ) ] , atom ( ) ) , [ float ( ) ] ) == { :badarg , [ integer ( ) ] }
1112- assert fun_apply ( fun ( [ integer ( ) ] , atom ( ) ) , [ term ( ) ] ) == { :badarg , [ integer ( ) ] }
1111+ assert fun_apply ( fun ( [ integer ( ) ] , atom ( ) ) , [ float ( ) ] ) == { :badarg , [ integer ( ) ] , false }
1112+ assert fun_apply ( fun ( [ integer ( ) ] , atom ( ) ) , [ term ( ) ] ) == { :badarg , [ integer ( ) ] , false }
11131113
11141114 # Union argument type: domain is int | float
11151115 assert fun_apply ( fun ( [ union ( integer ( ) , float ( ) ) ] , atom ( ) ) , [ integer ( ) ] ) == { :ok , atom ( ) }
11161116 assert fun_apply ( fun ( [ union ( integer ( ) , float ( ) ) ] , atom ( ) ) , [ float ( ) ] ) == { :ok , atom ( ) }
11171117
11181118 assert fun_apply ( fun ( [ union ( integer ( ) , float ( ) ) ] , atom ( ) ) , [ atom ( ) ] ) ==
1119- { :badarg , [ union ( integer ( ) , float ( ) ) ] }
1119+ { :badarg , [ union ( integer ( ) , float ( ) ) ] , false }
11201120
11211121 # 2-arity function
11221122 assert fun_apply ( fun ( [ integer ( ) , atom ( ) ] , binary ( ) ) , [ integer ( ) , atom ( ) ] ) == { :ok , binary ( ) }
11231123
11241124 assert fun_apply ( fun ( [ integer ( ) , atom ( ) ] , binary ( ) ) , [ boolean ( ) , atom ( ) ] ) ==
1125- { :badarg , [ integer ( ) , atom ( ) ] }
1125+ { :badarg , [ integer ( ) , atom ( ) ] , false }
11261126
11271127 # Return types
11281128 assert fun_apply ( fun ( [ integer ( ) ] , none ( ) ) , [ integer ( ) ] ) == { :ok , none ( ) }
@@ -1135,7 +1135,9 @@ defmodule Module.Types.DescrTest do
11351135 |> elem ( 1 )
11361136 |> equal? ( atom ( ) )
11371137
1138- assert fun_apply ( fun ( [ integer ( ) ] , atom ( ) ) , [ dynamic ( float ( ) ) ] ) == { :badarg , [ integer ( ) ] }
1138+ assert fun_apply ( fun ( [ integer ( ) ] , atom ( ) ) , [ dynamic ( float ( ) ) ] ) ==
1139+ { :badarg , [ integer ( ) ] , false }
1140+
11391141 assert fun_apply ( fun ( [ integer ( ) ] , atom ( ) ) , [ dynamic ( term ( ) ) ] ) == { :ok , dynamic ( ) }
11401142
11411143 # Arity mismatches
@@ -1198,7 +1200,7 @@ defmodule Module.Types.DescrTest do
11981200 assert fun_apply ( fun , [ dynamic ( integer ( ) ) ] ) == { :ok , union ( atom ( ) , dynamic ( ) ) }
11991201 assert fun_apply ( fun , [ dynamic ( number ( ) ) ] ) == { :ok , dynamic ( ) }
12001202 assert fun_apply ( fun , [ integer ( ) ] ) == { :ok , dynamic ( ) }
1201- assert fun_apply ( fun , [ float ( ) ] ) == { :badarg , [ dynamic ( integer ( ) ) ] }
1203+ assert fun_apply ( fun , [ float ( ) ] ) == { :badarg , [ dynamic ( integer ( ) ) ] , false }
12021204 end
12031205
12041206 defp dynamic_fun ( args , return ) , do: dynamic ( fun ( args , return ) )
@@ -1214,7 +1216,10 @@ defmodule Module.Types.DescrTest do
12141216 assert fun_apply ( dynamic_fun ( [ integer ( ) ] , atom ( ) ) , [ float ( ) ] ) == { :ok , dynamic ( ) }
12151217 assert fun_apply ( dynamic_fun ( [ integer ( ) ] , atom ( ) ) , [ term ( ) ] ) == { :ok , dynamic ( ) }
12161218 assert fun_apply ( dynamic_fun ( [ integer ( ) ] , none ( ) ) , [ integer ( ) ] ) == { :ok , dynamic ( none ( ) ) }
1217- assert fun_apply ( dynamic ( fun ( [ integer ( ) ] , integer ( ) ) ) , [ none ( ) ] ) == { :badarg , [ none ( ) ] }
1219+
1220+ assert fun_apply ( dynamic ( fun ( [ integer ( ) ] , integer ( ) ) ) , [ none ( ) ] ) ==
1221+ { :badarg , [ none ( ) ] , true }
1222+
12181223 assert fun_apply ( dynamic_fun ( [ integer ( ) ] , term ( ) ) , [ integer ( ) ] ) == { :ok , dynamic ( ) }
12191224
12201225 # Dynamic return and dynamic args
@@ -1330,15 +1335,17 @@ defmodule Module.Types.DescrTest do
13301335 )
13311336
13321337 assert fun_args |> fun_apply ( [ atom ( ) ] ) == { :ok , dynamic ( ) }
1333- assert fun_args |> fun_apply ( [ integer ( ) ] ) == { :badarg , [ dynamic ( atom ( ) ) ] }
1338+ assert fun_args |> fun_apply ( [ integer ( ) ] ) == { :badarg , [ dynamic ( atom ( ) ) ] , false }
13341339
13351340 # ((bool->bool) or dyn(int->int))
13361341 # booleans work, but not integers
13371342 fun_mixed_gdom = union ( fun ( [ boolean ( ) ] , boolean ( ) ) , dynamic_fun ( [ integer ( ) ] , integer ( ) ) )
13381343 assert fun_apply ( fun_mixed_gdom , [ boolean ( ) ] ) == { :ok , dynamic ( ) }
13391344 assert fun_apply ( fun_mixed_gdom , [ dynamic ( boolean ( ) ) ] ) == { :ok , union ( dynamic ( ) , boolean ( ) ) }
1340- assert fun_apply ( fun_mixed_gdom , [ integer ( ) ] ) == { :badarg , [ dynamic ( boolean ( ) ) ] }
1341- assert fun_apply ( fun_mixed_gdom , [ dynamic ( integer ( ) ) ] ) == { :badarg , [ dynamic ( boolean ( ) ) ] }
1345+ assert fun_apply ( fun_mixed_gdom , [ integer ( ) ] ) == { :badarg , [ dynamic ( boolean ( ) ) ] , false }
1346+
1347+ assert fun_apply ( fun_mixed_gdom , [ dynamic ( integer ( ) ) ] ) ==
1348+ { :badarg , [ dynamic ( boolean ( ) ) ] , false }
13421349
13431350 # Badfun
13441351 assert union (
@@ -2280,24 +2287,15 @@ defmodule Module.Types.DescrTest do
22802287 # This is a test of the map_update_fun/5 with forced?: false parameter.
22812288 # We check that it does not call its typed_fun argument with `none()`
22822289 # due to the key being absent in the map.
2283-
22842290 type = dynamic ( difference ( open_map ( ) , empty_map ( ) ) )
2285- ref = make_ref ( )
22862291
22872292 fun = fn _optional? , value ->
2288- send ( self ( ) , { ref , value } )
2293+ send ( self ( ) , :callback_invoked )
22892294 value
22902295 end
22912296
2292- _ = map_update_fun ( type , binary ( ) , fun , false , false )
2293-
2294- messages = Process . info ( self ( ) , :messages ) |> elem ( 1 )
2295-
2296- # Check that the callback was not invoked with `none()`
2297- refute Enum . any? ( messages , fn
2298- { seen_ref , value } when seen_ref == ref -> empty? ( value )
2299- _ -> false
2300- end )
2297+ assert map_update_fun ( type , binary ( ) , fun , false , false ) == { dynamic ( none ( ) ) , type , [ ] }
2298+ refute_received :callback_invoked
23012299 end
23022300
23032301 test "with dynamic atom keys" do
0 commit comments