-
-
Notifications
You must be signed in to change notification settings - Fork 609
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow template this parameter to work with static functions #18618
Labels
Comments
k.hara.pg commented on 2013-06-27T20:50:38ZThat was "accepts-invalid" bug.
Even with 2.062, it didn't work properly.
class Foo
{
static void instance (this T) () {}
}
void main ()
{
import std.typetuple;
foreach (T; TypeTuple!(Foo, const Foo, immutable Foo))
{
pragma(msg, T);
T.instance(); // fail to compile with const and immutable
}
}
static member function does not have valid 'this' expression, so compiler cannot deduce TemplateThisParameter with IFTI. |
doob (@jacob-carlborg) commented on 2013-06-28T01:29:36ZI thought that the whole point was to use it when "this" wasn't normally allowed. Just like typeof(this) can be used outside instance methods. |
schuetzm commented on 2015-10-25T12:02:53ZIMO the fact that `typeof(this)` is allowed in static methods is a compelling argument to allow this. It has interesting applications when combined with inheritance, see this forum post:
http://forum.dlang.org/post/n0gl6m$1oms$1@digitalmars.com
Therefore I'm reopening this issue as an enhancement request. |
nick (@ntrel) commented on 2018-02-01T13:41:05Z*** Issue 17713 has been marked as a duplicate of this issue. *** |
nick (@ntrel) commented on 2018-02-01T13:42:25ZThe above duplicate has a nice test case and also a comment that template this should be allowed anywhere inside a class, not just static function templates. |
nick (@ntrel) commented on 2018-03-09T19:06:07Z*** Issue 14191 has been marked as a duplicate of this issue. *** |
nick (@ntrel) commented on 2022-09-14T13:26:32Z*** Issue 20277 has been marked as a duplicate of this issue. *** |
dlang-bot commented on 2022-09-16T13:24:34Z@ntrel created dlang/dmd pull request #14446 "Infer template this parameter when calling static method on instance" mentioning this issue:
- Infer template this parameter when calling static method on instance
Part of Issue 10488 - Allow template this parameter with static functions.
Note: `tthis` is only used in `doHeaderInstantiation` for template this
so assigning null when there's a static storage class is not needed for
anything else.
https://github.com/dlang/dmd/pull/14446 |
dlang-bot commented on 2022-09-26T02:35:02Zdlang/dmd pull request #14446 "Infer template this parameter when calling static method on instance" was merged into master:
- 0121a59283ab9eb20b8fff646f90df7bd3fbfe13 by Nick Treleaven:
Infer template this parameter when calling static method on instance
Part of Issue 10488 - Allow template this parameter with static functions.
https://github.com/dlang/dmd/pull/14446 |
dlang-bot commented on 2022-09-27T14:46:41Z@maxhaton updated dlang/dmd pull request #14482 "Fix Issue 23368 - Don't segfault on throwing null exception" mentioning this issue:
- Infer template this parameter when calling static method on instance (#14446)
* Infer template this parameter when calling static method on instance
Part of Issue 10488 - Allow template this parameter with static functions.
* Apply suggestions from code review
Co-authored-by: Dennis <dkorpel@users.noreply.github.com>
Co-authored-by: Dennis <dkorpel@users.noreply.github.com>
https://github.com/dlang/dmd/pull/14482 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Jacob Carlborg (@jacob-carlborg) reported this on 2013-06-27T08:54:06Z
Transferred from https://issues.dlang.org/show_bug.cgi?id=10488
CC List
Description
This code compiled with 2.062: class Foo { static void instance (this T) () { } } void main () { Foo.instance(); } With 2.063 I get this error: main.d(10): Error: template main.Foo.instance does not match any function template declaration. Candidates are: main.d(3): main.Foo.instance(this T)() main.d(10): Error: template main.Foo.instance(this T)() cannot deduce template function from argument types !()()The text was updated successfully, but these errors were encountered: