Skip to content

Commit

Permalink
Raise clearer error message if struct is missing on type checker
Browse files Browse the repository at this point in the history
  • Loading branch information
josevalim committed Aug 9, 2024
1 parent e770710 commit 00f8b1e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/elixir/lib/module/types/of.ex
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,15 @@ defmodule Module.Types.Of do
# TODO: Use the struct default values to define the default types.
def struct(struct, args_types, default_handling, meta, stack, context) do
context = remote(struct, :__struct__, 0, meta, stack, context)

info =
struct.__info__(:struct) ||
raise "expected #{inspect(struct)} to return struct metadata, but got none"

term = term()

defaults =
for %{field: field} <- struct.__info__(:struct), field != :__struct__ do
for %{field: field} <- info, field != :__struct__ do
{field, term}
end

Expand Down

0 comments on commit 00f8b1e

Please sign in to comment.