--- Comment #5 from Don <> 2012-03-16 23:47:01 PDT ---
(In reply to comment #2)
> (In reply to comment #1)
> > It's not clear that there's a bug here. typeof(this).init correctly 
> > shouldn't
> > compile inside a mixin, because the mixin might add an extra field
> It does not add an extra field.
> > -- so then init would change.
> If I added some random character to a valid d program, then it would likely 
> not
> be valid anymore. What does this prove?

The point is that accessing .init from inside a mixin is not valid in the
general case. Although in this specific example, it could be made to work, that
isn't true in general.
Likewise, .sizeof is not defined until all declarations have been run.

> > .init is defined only when all possible members of the aggregate have been
> > declared.
> This is the case in the example. What should be illegal is adding a field that
> changes .init based on a static condition that depends on .init. This would be
> part of a necessary general overhaul of symbol lookup works in DMD: Forward
> declarations and compile-time reflection make it possible to write
> contradictory or ambiguous D programs. The compiler should detect such setups
> in the least conservative way we can come up with.

OK. That's clearly an enhancement request. Compiler is working as designed.
This only seemed to compile before, because of a compiler bug.

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to