D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 5252 - pure nothrow Rebindable
Summary: pure nothrow Rebindable
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: All All
: P2 enhancement
Assignee: No Owner
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2010-11-21 16:39 UTC by bearophile_hugs
Modified: 2011-09-09 09:54 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description bearophile_hugs 2010-11-21 16:39:57 UTC
This program looks correct:


import std.typecons: Rebindable;
const class Foo {}
pure nothrow void bar() {
    Rebindable!Foo f = new Foo;
}
void main() {}


But DMD 2.050 shows the errors:

test.d(4): Error: pure function 'bar' cannot call impure function 'this'
test.d(3): Error: function test3.bar 'bar' is nothrow yet may throw


(I don't know if this is possible in all cases, like when Rebindable is used on a struct with a nonpure postblit. But with class references I think this is possible).
Comment 1 Kenji Hara 2011-09-09 07:59:31 UTC
Maybe this issue was fixed by pure nothrow inference feature.

In 2.055, that code can compile.