function and variable

Rikki Cattermole via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Feb 9 19:59:19 PST 2015


On 10/02/2015 4:28 p.m., Fyodor Ustinov wrote:
> Hi!
>
> I think this code should not be compiled without any warning:
>
> import std.stdio;
>
> void f(int a) {
>      writeln("it's a function! : ", a);
> }
>
> void main() {
>      auto f = function (int a) {writeln("It's a variable! : ", a);};
>      5.f();
>      f(5);
> }
>
> Output:
>
> it's a function! : 5
> It's a variable! : 5
>
> WBR,
>      Fyodor.

That's a bug. It should be using the function pointer.

UFCS call should abide by the same scoping rules as anything else.
https://issues.dlang.org/show_bug.cgi?id=14161


More information about the Digitalmars-d-learn mailing list