iex(16)> struct!(YY,field: 1)
%XX{field: 1}
iex(17)> struct!(%YY{},field: 1)
%YY{field: 1}
I suspect the bug is with Kernel.struct!/2, not Kernel.SpecialForms.%/2.
https://github.com/elixir-lang/elixir/blob/v1.8.1/lib/elixir/lib/kernel.ex#L2116-L2130
As you discovered, it only presents when you start defdelegating the constructor and I don’t think this code anticipated that.
So the question is - what are you trying to accomplish by defdelegating the struct constructor to another struct? Sharing code between XX and YY should probably be accomplished via a shared third module.


















