[Issue 17387] New: static struct this(ref) not pure
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Tue May 9 08:07:32 PDT 2017
https://issues.dlang.org/show_bug.cgi?id=17387
Issue ID: 17387
Summary: static struct this(ref) not pure
Product: D
Version: D2
Hardware: x86
OS: Windows
Status: NEW
Severity: minor
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: nick at geany.org
struct S { this(ref int val) { ++val; } }
pure unittest
{
int val = 3;
auto s = S(val);
assert(val == 4);
}
The above fails to compile with dmd v2.074.0:
purestaticstruct.d(6): Error: pure function 'purestaticstruct.__unittestL3_1'
cannot call impure constructor 'purestaticstruct.S.this'
If the struct is moved inside the unittest, it compiles as expected.
--
More information about the Digitalmars-d-bugs
mailing list