Skip to content

Commit 6a24baf

Browse files
committed
Tag exceptions as dynamic, closes #14074
1 parent 8ddef06 commit 6a24baf

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,8 @@ defmodule Module.Types.Expr do
444444
# to avoid export dependencies. So we do it here.
445445
if Code.ensure_loaded?(exception) and function_exported?(exception, :__struct__, 0) do
446446
{info, context} = Of.struct_info(exception, meta, stack, context)
447-
{Of.struct_type(exception, info, args), context}
447+
# TODO: For properly defined structs, this should not be dynamic
448+
{dynamic(Of.struct_type(exception, info, args)), context}
448449
else
449450
# If the exception cannot be found or is invalid, fetch the signature to emit warnings.
450451
{_, context} = Apply.signature(exception, :__struct__, 0, meta, stack, context)

lib/elixir/test/elixir/module/types/expr_test.exs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1224,16 +1224,18 @@ defmodule Module.Types.ExprTest do
12241224
e
12251225
end
12261226
) ==
1227-
union(
1228-
closed_map(
1229-
__struct__: atom([ArgumentError]),
1230-
__exception__: atom([true]),
1231-
message: term()
1232-
),
1233-
closed_map(
1234-
__struct__: atom([RuntimeError]),
1235-
__exception__: atom([true]),
1236-
message: term()
1227+
dynamic(
1228+
union(
1229+
closed_map(
1230+
__struct__: atom([ArgumentError]),
1231+
__exception__: atom([true]),
1232+
message: term()
1233+
),
1234+
closed_map(
1235+
__struct__: atom([RuntimeError]),
1236+
__exception__: atom([true]),
1237+
message: term()
1238+
)
12371239
)
12381240
)
12391241
end

0 commit comments

Comments
 (0)