www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 14227] New: Incorrect passed a delegate as argument with null

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

          Issue ID: 14227
           Summary: Incorrect passed a delegate as argument with null
                    value.
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: major
          Priority: P1
         Component: DMD
          Assignee: nobody puremagic.com
          Reporter: alexey.poryadin gmail.com

import std.stdio;

class Class
{
    void set(int a, double b, void delegate(int revents) callback)
    {
        writefln("(callback !is null) %s", (callback !is null));
    }
}

void main()
{
    auto c = new Class;
    c.set(1, 1, null); // prints: (callback !is null) true
    c.set(1, 1, null); // prints: (callback !is null) false
}
-----
Very strange. It dependent on previous argument number and types. For example
if they both has type int, it work correct.

DMD64 D Compiler v2.066.1

x86_64 x86_64 x86_64 GNU/Linux

--
Feb 26 2015