[Issue 8446] Can't use 'this' pointer in pure member function?

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Nov 9 10:50:44 PST 2012


http://d.puremagic.com/issues/show_bug.cgi?id=8446



--- Comment #2 from Dmitry Olshansky <dmitry.olsh at gmail.com> 2012-11-09 10:50:40 PST ---
(In reply to comment #1)
> (In reply to comment #0)
> 
> This is a trivial bug of the original code.
> 
> >    @property auto byInterval() pure const
> >    {
> >        static struct IntervalRange
> >        {
>              this(in RleBitSet set_) // should be pure
> >            {
> >            }            
> >        }
>          return IntervalRange(this); // needs pure constructor
> >    }

Thanks, it's indeed obvious from the perspective. But since this was a
parameter, it didn't occur to me it means constructor of IntervalRange that is
not pure. Must have been angry already.

I'd still argue that error message is not helpful.

Error: pure function 'byInterval' cannot call impure function 'this'

There is no idication of which 'this' it talks about. Would it be better if it
listed IntervalRange.this?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list