[dmd-internals] Fixing forward ref bugs for good

Don Clugston dclugston at googlemail.com
Thu Sep 15 02:44:58 PDT 2011


On 15 September 2011 09:11, Rainer Schuetze <r.sagitario at gmx.de> wrote:
> On 15.09.2011 09:00, Don Clugston wrote:
>>
>> On 15 September 2011 08:29, Rainer Schuetze<r.sagitario at gmx.de>  wrote:
>>>
>>> What happens, if the evaluation of "static if" turns out to require
>>> symbols
>>> from the same scope? (Something I did not mention above: unconditionally
>>> existing or expanded members of a scope should be added to the symbol
>>> lookup
>>> as soon as possible.) My current suggestion is: do not recurse into the
>>> expansion of "complex" members, just use the currently available symbols.
>>
>> What do you mean by "complex" members?
>
> "complex" in the sense of my (no longer quoted) initial mail: the members
> that have to be expanded before searching the scope is normally possible,
> i.e. static-if and mixins. They need semantic analysis before they might
> expand to new members that add more symbols to the scope.

I think there is a simple solution to 'static if'.
Do const folding on every static if condition, giving a boolean result.
Do NOT evaluate any static if bodies yet.
This would have the same effect as if every 'static if' were evaluated
simultaneously.
(There's a little bit of complexity with is() expressions that create
symbols, they need to be cached but not added to the scope yet).

Possibly const-fold every string mixin as well; this would make them
also act as if they were all evaluated simultaneously.
I don't know what should be done about template mixins though. But
they might not be much of a problem.
When this is complete, add all declarations from each static if body,
and from every mixin, into the scope.
When they're all inserted, look for static ifs and mixins again.
Repeat the process until none are left.


More information about the dmd-internals mailing list