Error message: (CompileError) cannot access struct CustomSet, the struct was not yet defined or the struct is being accessed in the same context that defines it expanding struct: CustomSet.__struct__/0
Hi. What’s the code you’re running that’s resulting in that error?
Have you used the defstruct
command in your solution?
Error shows at start. When you open exercise.
defmodule CustomSet do
@opaque t :: %__MODULE__{map: map}
@spec new(Enum.t()) :: t
def new(enumerable) do
end
@spec empty?(t) :: boolean
def empty?(custom_set) do
end
@spec contains?(t, any) :: boolean
def contains?(custom_set, element) do
end
@spec subset?(t, t) :: boolean
def subset?(custom_set_1, custom_set_2) do
end
@spec disjoint?(t, t) :: boolean
def disjoint?(custom_set_1, custom_set_2) do
end
@spec equal?(t, t) :: boolean
def equal?(custom_set_1, custom_set_2) do
end
@spec add(t, any) :: t
def add(custom_set, element) do
end
@spec intersection(t, t) :: t
def intersection(custom_set_1, custom_set_2) do
end
@spec difference(t, t) :: t
def difference(custom_set_1, custom_set_2) do
end
@spec union(t, t) :: t
def union(custom_set_1, custom_set_2) do
end
end
Full error message:
lib/custom_set.ex:41: CustomSet.union/2
== Compilation error in file lib/custom_set.ex ==
** (CompileError) lib/custom_set.ex:2: cannot access struct CustomSet, the struct was not yet defined or the struct
is being accessed in the same context that defines it
expanding struct: CustomSet.struct/0
lib/custom_set.ex:2: CustomSet (module)
I didn’t try to solve exercise when I noticed it doesn’t compile. I solved over 100 exercises and this is the first one which shows errors at start. But ok, no problem. I thought this exercise should be changed slightly, so it compile. But if this exercise for you is ok, is ok for me too. End of topic.