Skip to content

Commit 00f8b1e

Browse files
committed
Raise clearer error message if struct is missing on type checker
1 parent e770710 commit 00f8b1e

File tree

1 file changed

+6
-1
lines changed
  • lib/elixir/lib/module/types

1 file changed

+6
-1
lines changed

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

+6-1
Original file line numberDiff line numberDiff line change
@@ -176,10 +176,15 @@ defmodule Module.Types.Of do
176176
# TODO: Use the struct default values to define the default types.
177177
def struct(struct, args_types, default_handling, meta, stack, context) do
178178
context = remote(struct, :__struct__, 0, meta, stack, context)
179+
180+
info =
181+
struct.__info__(:struct) ||
182+
raise "expected #{inspect(struct)} to return struct metadata, but got none"
183+
179184
term = term()
180185

181186
defaults =
182-
for %{field: field} <- struct.__info__(:struct), field != :__struct__ do
187+
for %{field: field} <- info, field != :__struct__ do
183188
{field, term}
184189
end
185190

0 commit comments

Comments
 (0)