Re: Template alias parameter: error: need 'this' for ...

2023-02-24 Thread Elfstone via Digitalmars-d-learn
On Friday, 24 February 2023 at 15:28:18 UTC, Steven Schveighoffer wrote: On 2/24/23 7:00 AM, Elfstone wrote: Seems like the same bug is still there after ten years. `static` should not affect module-level functions, but also, this code should work without `static`. Reported, not sure if t

Re: Template alias parameter: error: need 'this' for ...

2023-02-24 Thread Paul Backus via Digitalmars-d-learn
On Friday, 24 February 2023 at 14:22:17 UTC, user1234 wrote: you can break using `goto`, restore `static` everywhere, and using local introspection determine whether the result exists. ```d struct Bar { @("hello") int t; } static bool hasAttribute(alias F, T)() { static foreach

Re: Template alias parameter: error: need 'this' for ...

2023-02-24 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/24/23 7:00 AM, Elfstone wrote: Seems like the same bug is still there after ten years. `static` should not affect module-level functions, but also, this code should work without `static`. Reported, not sure if there's a previous bug, it was hard to come up with a good description:

Re: Template alias parameter: error: need 'this' for ...

2023-02-24 Thread user1234 via Digitalmars-d-learn
On Friday, 24 February 2023 at 12:00:41 UTC, Elfstone wrote: Seems like the same bug is still there after ten years. ```d struct Bar { @("hello") int t; } static bool hasAttribute(alias F, T)() { bool result = false;

Template alias parameter: error: need 'this' for ...

2023-02-24 Thread Elfstone via Digitalmars-d-learn
https://forum.dlang.org/post/imnannjdgtjnlzevh...@forum.dlang.org On Saturday, 24 August 2013 at 11:47:43 UTC, Matej Nanut wrote: On Friday, 23 August 2013 at 22:54:33 UTC, Jonathan M Davis wrote: Because without static it's a member variable, which means that you have to have a constructed obj

Re: Template alias parameter: error: need 'this' for ...

2013-08-24 Thread Matej Nanut
On Friday, 23 August 2013 at 22:54:33 UTC, Jonathan M Davis wrote: Because without static it's a member variable, which means that you have to have a constructed object to access it (since it's part of the object). When you declare a variable in a class or struct static, then there's only one f

Re: Template alias parameter: error: need 'this' for ...

2013-08-23 Thread Jonathan M Davis
On Friday, August 23, 2013 23:28:46 Matej Nanut wrote: > Hello! > > I've run into this issue that I don't understand, maybe someone > can enlighten me. :) > > This code: > --- > struct Thing > { > int i; > } > > void main() > { > t!(Thing.i)(); > } > > void t(alias a)() > { > return; > } > ---

Template alias parameter: error: need 'this' for ...

2013-08-23 Thread Matej Nanut
Hello! I've run into this issue that I don't understand, maybe someone can enlighten me. :) This code: --- struct Thing { int i; } void main() { t!(Thing.i)(); } void t(alias a)() { return; } --- fails to compile with: ‘Error: need 'this' for 't' of type 'pure nothrow @safe voi