Kenji Hara <> changed:

           What    |Removed                     |Added
            Version|unspecified                 |D2

--- Comment #1 from Kenji Hara <> 2012-09-10 08:14:02 PDT ---
(In reply to comment #0)
> The argument taken by enforce must be "castable to bool", so the the
> implementation can do the cast. However, enforce is declared pure, so if the
> cast operator is not pure, the compilation fails:
> --------
> Error: pure function 'enforce' cannot call impure function '~this'
> Error: pure function 'enforce' cannot call impure function 'opCast'
> --------

The cause might be the explicit annotation with pure.

> The messages come from:
> --------
> T enforce(T)(T value, lazy const(char)[] msg = null, string file = __FILE__,
> size_t line = __LINE__) @safe pure
> {
>     if (!value) bailOut(file, line, msg);
>     return value;
> }
> --------
> "if(!value)": This makes an impure call to opCast.
> "enforce(T)(T value..." This uses pass by value, and makes an impure call to
> the destructor
> I have no idea what a good fix would be. Regarding pass by value, wouldn't 
> this
> be a textbook example of using "auto ref" with "auto return"? I have no 
> idea...

The strict pure annotation is introduced by the pull #263.

As you can see, the pure annotations were just for the documentation. At this
point, impure destructor had not been considered at all in the discussion.

Then, now, the pure annotation causes this problem, so I think we should remove
it and rely on the pure attribute inference.

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

Reply via email to