Make `& Class.foo` illegal
Avrina
avrina12309412342 at gmail.com
Thu Aug 27 11:58:26 UTC 2020
On Thursday, 27 August 2020 at 11:20:17 UTC, Johan wrote:
> Currently this code is not rejected by the compiler and instead
> creates non-functioning (undefined) code:
> ```
> struct S {
> void foo() {}
> }
>
> void main() {
> auto a = &S.foo;
> }
> ```
>
> See https://issues.dlang.org/show_bug.cgi?id=21195 .
>
> Considering https://www.digitalmars.com/articles/b68.html, why
> not simply reject `&S.foo` during semantic analysis?
>
> -Johan
This gets brought up often. The last issue was closed as invalid.
This will likely never get fixed, the issue is that it is return
a function type, when it should be a delegate type with a null
"this" ptr.
"Just use @safe"
https://issues.dlang.org/show_bug.cgi?id=3720#c16
More information about the Digitalmars-d
mailing list