Skip to content

Struct undefined, cannot expand struct #35

Description

@cafrias

Hello 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!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions