Struct undefined, cannot expand struct
See original GitHub issueHello there!
I have two modules defined in different files, one is using the struct defined in the other, as the following code explains:
# ./lib/identicon.ex
defmodule Identicon do
def hash_input(input) do
hex = :crypto.hash(:md5, input)
|> :binary.bin_to_list()
# I'm getting the error in the line below
%Identicon.Image{hex: hex}
end
end
# ./lib/image.ex
defmodule Identicon.Image do
defstruct hex: nil, color: nil, grid: nil, pixel_map: nil
end
The exact error I get from elixirlinter is the following:
Error: Identicon.Image.__struct__/0 is undefined, cannot expand struct Identicon.Image
The application is running perfectly when executed using iex -S mix.
It seems that I can’t load external dependencies for the current file. My question is how to do that? Is there any better approach?
Thanks in advance!
Issue Analytics
- State:
- Created 7 years ago
- Reactions:6
- Comments:9
Top Results From Across the Web
Cannot expand struct - elixir/phoenix - Stack Overflow
__struct__/1 is undefined, cannot expand struct Locations . BTW I'm new to elixir so I'm probably doing something really obvious wrong.
Read more >Questions / Help - Elixir Forum
Hi all I have following struct definition: @enforce_keys [:uri, :user, ... Worker.__struct__/0 is undefined, cannot expand struct Worker.
Read more >Today I Learned: Aliasing an Elixir Module Within Itself
__struct__/0 is undefined, cannot expand struct Post. The issue was in a function I defined in the module. def changeset(%Post{}= post, ...
Read more >Introduction to Mix - Joy of Elixir
__struct__/0 is undefined, cannot expand struct Person. ... This error is occurring because Elixir cannot find a module called Person anymore.
Read more >Problem placing helper .ex files into test directory. Somehow ...
__struct__/0 is undefined, cannot expand struct TestRuntimeCtx. (elixir) src/elixir_map.erl:44: :elixir_map.translate_struct/4.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

+1 here, I’m following the same course and have the same issue.
Has anyone found a solution to this? I’m following the same course and have the exact same issue