Bug 10886 – Typeof on @property function triggers 'wrong this' type error
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-08-24T14:37:48Z
Last change time
2023-03-16T01:20:49Z
Keywords
pull
Assigned to
No Owner
Creator
Temtaime
Comments
Comment #0 by temtaime — 2013-08-24T14:37:48Z
struct A {
pure auto foo() @property { return 0; }
}
struct B {
void bar(T)() {
alias B = typeof(T.foo);
}
}
void main() {
B b;
b.bar!A();
}
Output:
Error: this for foo needs to be type A not type B
Error: template instance hello.B.bar!(A) error instantiating
Comment #1 by temtaime — 2013-08-24T14:39:33Z
Reduced declaration of foo:
int foo() @property { return 0; }
Problem goes away if @property is removed.
Comment #2 by andrej.mitrovich — 2013-08-24T14:41:46Z
It's unrelated to templates:
-----
struct A
{
@property int foo() { return 0; }
int bar() { return 0; }
}
struct B
{
void bar()
{
alias f = typeof(A.foo); // NG
alias b = typeof(A.bar); // ok
}
}
void main()
{
}
-----
AFAIK there are/will be changes to how typeof() works with properties as well.
Comment #3 by temtaime — 2013-08-24T14:47:41Z
Oh, yes, sorry. It's too late where i am, so my example is ugly.
Comment #4 by dlang-bot — 2023-03-08T15:15:22Z
@RazvanN7 created dlang/dmd pull request #14969 "Fix Issue 21288 & 10886 - incorrect this pointer" fixing this issue:
- Fix Issue 21288 & 10886 - incorrect this pointer
https://github.com/dlang/dmd/pull/14969
Comment #5 by dlang-bot — 2023-03-13T09:17:49Z
dlang/dmd pull request #14969 "Fix Issue 21288 & 10886 - incorrect this pointer" was merged into stable:
- 30a91c21347eaaebd8b27bb4598726422110c555 by RazvanN7:
Fix Issue 21288 & 10886 - incorrect this pointer
https://github.com/dlang/dmd/pull/14969
Comment #6 by dlang-bot — 2023-03-16T01:20:49Z
dlang/dmd pull request #14992 "merge stable" was merged into master:
- 141c5683f69d5a483d6f1647950249510a025961 by Razvan Nitu:
Fix Issue 21288 & 10886 - incorrect this pointer (#14969)
https://github.com/dlang/dmd/pull/14992