On Monday, 16 July 2018 at 13:13:53 UTC, Timoses wrote:
On Monday, 16 July 2018 at 12:00:57 UTC, Simen Kjærås wrote:
On Monday, 16 July 2018 at 11:43:03 UTC, Timoses wrote:
Why does this fail?
It doesn't. Not using DMD 2.081.1 under Windows, at least. I
tried adding a bitfield since you mentioned it, but it
compiles nicely for me. Which version of DMD are you using,
and are you having the issues with the exact code you posted
here?
--
Simen
https://run.dlang.io/is/Pgs527
I'm on 2.080.1. But above is on latest 2.081.1 I believe.
Note that the bottom code snippet in the original post does
work, while the first one does not.
That makes sense. The problem is F has a context pointer to the
main() block, since it's a non-static struct with methods inside
a block. It doesn't actually use the context pointer for
anything, so it possibly shouldn't have one, but it does, so we
have to work around it.
The fix is to mark F as static, or move it outside the main()
block.
--
Simen