Skip to content

NullReferenceException when checking if NDArray is null #290

@Plankton555

Description

@Plankton555

Summary
It doesn't seem to be possible to use if (myArray == null) to check whether myArray is null, if it has been initialized to NDArray myArray = null;. This is because the == operator has been overridden without any additional checks.

Minimal example of bug

static void Main(string[] args)
{
    NDArray myArray = null;

    if (myArray == null) // NullReferenceException is thrown here
    {
        Debug.WriteLine("myArray is null");
    }
}

Expected behaviour
myArray == null should return true, not throw a NullReferenceException.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions