[Issue 20233] New: opDispatch hides alias this properties
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sat Sep 21 03:34:09 UTC 2019
https://issues.dlang.org/show_bug.cgi?id=20233
Issue ID: 20233
Summary: opDispatch hides alias this properties
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Severity: normal
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: micia at inventati.org
In presence of `alias this`, `opDispatch` causes the compiler to ignore
any plain member of the aliased field which is not a property nor a callable
method. This reduces `alias this` usefulness and is possibly a bug.
This is possibly caused by the fact that `opDispatch` takes precedence
over `alias this`.
-----
module main;
struct Point
{
int[2] coords;
alias coords this;
auto opDispatch(string name, A...)(args)
{
return mixin("this.coords." ~ name ~ "(args)");
}
}
void main()
{
import std.stdio;
Point p;
writeln(p.ptr, p.length);
}
-----
$ dmd alias-dispatch.d
alias-dispatch.d(20): Error: no property ptr for type Point
alias-dispatch.d(20): Error: no property length for type Point
--
More information about the Digitalmars-d-bugs
mailing list