[Issue 23234] Delegate literal with inferred return value that requires following alias-this uses class cast instead.

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Jul 13 09:07:10 UTC 2022


https://issues.dlang.org/show_bug.cgi?id=23234

--- Comment #4 from RazvanN <razvan.nitu1305 at gmail.com> ---
This issue is invalid. The return type of a delegate should be decided based
upon what the function returns, not on how the returned result is used.

For example, consider this code:

alias fd = () => foo;
test(fd);

By the time the compiler calls test, fd's type has already been established to
foo. The fact that -vcg-ast shows that the delegate return contains a cast to
Bar is indeed a bug, however, the expectation that it should return `foo.get`
is not justified.

--


More information about the Digitalmars-d-bugs mailing list