http://d.puremagic.com/issues/show_bug.cgi?id=4417
Summary: const-violation in struct error message Product: D Version: D2 Platform: x86 OS/Version: Windows Status: NEW Keywords: diagnostic Severity: enhancement Priority: P2 Component: DMD AssignedTo: nob...@puremagic.com ReportedBy: bearophile_h...@eml.cc --- Comment #0 from bearophile_h...@eml.cc 2010-07-02 05:31:17 PDT --- This D2 program is wrong, because the rnd field of Foo must change its state, so it can't be called in a const method bar(): import std.random: MinstdRand, uniform; struct Foo { MinstdRand rnd; int bar() const { return uniform(0, 10, rnd); } } void main() {} But dmd v2.047 shows bad error messages: ...\dmd\src\phobos\std\random.d(684): Error: function std.random.LinearCongruentialEngine!(uint,48271,0,2147483647).LinearCongruentialEngine.front () is not callable using argument types () ...\dmd\src\phobos\std\random.d(685): Error: function std.random.LinearCongruentialEngine!(uint,48271,0,2147483647).LinearCongruentialEngine.popFront () is not callable using argument types () ...\dmd\src\phobos\std\random.d(5): Error: template instance std.random.uniform!("[)",int,int,const(LinearCongruentialEngine!(uint,48271,0,2147483647))) error instantiating A better single error message can just say that uniform(_, _, rnd) can't be called inside bar() because uniform() tries to mutates rnd while bar is const. See also bug 4416 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------