Re: [elixir-core:8489] What does %Mod{} really do?

45 views
Skip to first unread message

José Valim

unread,
Feb 15, 2019, 10:48:31 AM2/15/19
to elixir-l...@googlegroups.com
Please do a bug report. We should either raise or just trust the value returned by __struct__/0 since we don't validate it anywhere else.


José Valim
Skype: jv.ptec
Founder and Director of R&D


On Fri, Feb 15, 2019 at 2:47 PM Mário Guimarães <mario.luis...@gmail.com> wrote:
Hello,

given the files `xx.ex` and `yy.ex` defined as

defmodule XX do
  defstruct
[:field]
end

defmodule YY do
  defdelegate __struct__
, to: XX
  defdelegate __struct__
(x), to: XX
end

why does 

iex(1)> %XX{} == XX.__struct__()
true

and 

iex(2)> %YY{} == YY.__struct__()
false

?

It seems that %Mod{} is not equivalent to Mod.__struct__().

What does %Mod{} really do?

Thanks
Mário

--
You received this message because you are subscribed to the Google Groups "elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/0a942906-d08a-48fc-84a9-e80d19b048f4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Mário Guimarães

unread,
Feb 15, 2019, 11:33:18 AM2/15/19
to elixir-lang-core
Ok, I will write a report 

Mário Guimarães

unread,
Feb 15, 2019, 12:15:52 PM2/15/19
to elixir-lang-core
Reply all
Reply to author
Forward
0 new messages