You know how I was saying in my DConf talk...
Timon Gehr
timon.gehr at gmx.ch
Wed Jul 24 03:10:33 UTC 2019
On 24.07.19 04:12, Ethan wrote:
> On Wednesday, 24 July 2019 at 01:10:34 UTC, Ethan wrote:
>> On Wednesday, 24 July 2019 at 01:06:18 UTC, Ethan wrote:
>>>
>>
>> It's 4am and I was planning on having a major feature finished 8 hours
>> ago, but I've been running in to static foreach and mixin bugs all day.
>
> https://issues.dlang.org/show_bug.cgi?id=20079
> https://issues.dlang.org/show_bug.cgi?id=20080
> ...
This behavior is by design (for the better or worse, but those are not
compiler bugs). You'd need to alias the mixin-template-local symbols
into the current scope, or use string mixins instead of template mixins.
> ........and when trying to get to sleep, I decided to try forward
> declarations for the functions I was having issues with in mixins. And
> finally hit upon what I think are the root problems I've been having.
>
> Mixin templates have been broken in one way or another since I started
> using D in 2012. This static foreach bug I've found just seems to
> highlight to me that the method of defining a separate scope and
> importing in to the parent after the fact just plain doesn't work.
mixin templates are _designed_ that way, but `static foreach` doesn't
work like this. The additional scopes are introduced for the purpose of
containing the `static foreach` loop variable symbols, the symbols
generated by `static foreach` themselves are _not_ treated like template
mixins, they are inserted into the symbol table of the enclosing scope,
but they need to be analyzed in the inner scope so the `static foreach`
loop variable is visible.
The `static foreach` implementation explicitly skips scopes containing
`static foreach` loop variables (the __anonymous in the error messages)
when determining parent symbols, so there is something weird going on.
I'm trying to look into this, but I don't have that much time and for
some reason the compiler doesn't build on my machine right now (linker
errors)...
I have no idea what's up with the visibility problems, as I haven't
worked on that part of DMD's code, but probably there is a bad
interaction between the code that checks for symbol visibility and
`static foreach` loop variable scopes.
More information about the Digitalmars-d
mailing list