digitalmars.D.learn - dmd 2.068 deducing purity
- Jack Applegame (4/24) Aug 25 2015 Also after switching to dmd 2.068 I got many stupid errors in
- Steven Schveighoffer (5/30) Aug 25 2015 That seems like a bug, I see no pure in sight there, the compiler
- Jack Applegame (12/13) Aug 25 2015 import std.range;
- Steven Schveighoffer (3/15) Aug 25 2015 https://issues.dlang.org/show_bug.cgi?id=14962
- Jack Applegame (3/5) Aug 25 2015 Thanks.
Using lambdas in 2.068 becomes painful:import std.algorithm; struct Foo { int baz(int v) { static int id; return v + id++; } void bar() { auto arr1 = [1, 2, 3]; auto arr2 = [4, 5, 6]; arr1.map!(i => arr2.map!(j => baz(i + j)) ); } } void main() { }Error: pure function 'bug.Foo.bar.__lambda1!int.__lambda1.__lambda2' cannot call impure function 'bug.Foo.baz'Also after switching to dmd 2.068 I got many stupid errors in lambdas (defined inside class non-static functions):Error: need 'this' for '...' of type '...'I have no idea how to fix it and had to go back to 2.067.
Aug 25 2015
On 8/25/15 9:59 AM, Jack Applegame wrote:Using lambdas in 2.068 becomes painful:That seems like a bug, I see no pure in sight there, the compiler shouldn't infer pure if the inferred function is calling impure functions.import std.algorithm; struct Foo { int baz(int v) { static int id; return v + id++; } void bar() { auto arr1 = [1, 2, 3]; auto arr2 = [4, 5, 6]; arr1.map!(i => arr2.map!(j => baz(i + j)) ); } } void main() { }Error: pure function 'bug.Foo.bar.__lambda1!int.__lambda1.__lambda2' cannot call impure function 'bug.Foo.baz'Also after switching to dmd 2.068 I got many stupid errors in lambdas (defined inside class non-static functions):Can you post an example? -SteveError: need 'this' for '...' of type '...'I have no idea how to fix it and had to go back to 2.067.
Aug 25 2015
On Tuesday, 25 August 2015 at 14:05:17 UTC, Steven Schveighoffer wrote:Can you post an example?import std.range; import std.algorithm; class Foo { int baz() { return 1;} void bar() { auto s = [1].map!(i => baz()); // compiles auto r = [1].map!(i => [1].map!(j => baz())); // Error: need 'this' for 'baz' of type 'int()' } }
Aug 25 2015
On 8/25/15 1:05 PM, Jack Applegame wrote:On Tuesday, 25 August 2015 at 14:05:17 UTC, Steven Schveighoffer wrote:https://issues.dlang.org/show_bug.cgi?id=14962 -SteveCan you post an example?import std.range; import std.algorithm; class Foo { int baz() { return 1;} void bar() { auto s = [1].map!(i => baz()); // compiles auto r = [1].map!(i => [1].map!(j => baz())); // Error: need 'this' for 'baz' of type 'int()' } }
Aug 25 2015
On Tuesday, 25 August 2015 at 18:03:21 UTC, Steven Schveighoffer wrote:https://issues.dlang.org/show_bug.cgi?id=14962 -SteveThanks.
Aug 25 2015