Skip to content

Commit cfc43b3

Browse files
committed
Add notes to the code
1 parent 57c254f commit cfc43b3

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

lib/elixir/lib/module/types/expr.ex

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ defmodule Module.Types.Expr do
1515
list_of_modules = list(atom())
1616

1717
@try_catch atom([:error, :exit, :throw])
18+
@atom_true atom([true])
1819

1920
@caller closed_map(
2021
__struct__: atom([Macro.Env]),
@@ -34,9 +35,12 @@ defmodule Module.Types.Expr do
3435
versioned_vars: open_map()
3536
)
3637

37-
# An annotation for terms where the reverse arrow is not yet fully defined
38+
# An annotation for terms where the reverse arrow is not yet fully defined.
39+
# Also revisit all users of dynamic() in this module in a later date.
3840
@pending term()
39-
@atom_true atom([true])
41+
42+
# We do not make exception dynamic on purpose. If you do a blank rescue,
43+
# then we will assume you need to statically handle all possible exceptions.
4044
@exception open_map(__struct__: atom(), __exception__: @atom_true)
4145

4246
args_or_arity = union(list(term()), integer())
@@ -346,7 +350,7 @@ defmodule Module.Types.Expr do
346350

347351
if stack.mode == :traversal do
348352
{_acc, context} = of_clauses(clauses, domain, @pending, nil, :fn, stack, context, none())
349-
{dynamic(fun(length(patterns))), context}
353+
{dynamic(), context}
350354
else
351355
{acc, context} =
352356
of_clauses_fun(clauses, domain, @pending, nil, :fn, stack, context, [], fn

lib/elixir/lib/module/types/of.ex

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,10 @@ defmodule Module.Types.Of do
146146
end
147147

148148
def impl(struct) do
149-
# Elixir did not strictly require the implementation to be available, so we need a fallback.
149+
# Elixir did not strictly require the implementation to be available,
150+
# so we need to deal with such cases accordingly.
150151
# TODO: Assume implementation is available on Elixir v2.0.
152+
# A warning is emitted since v1.19+.
151153
if info = Code.ensure_loaded?(struct) && struct.__info__(:struct) do
152154
struct_type(struct, info)
153155
else

0 commit comments

Comments
 (0)