Skip to content

Incorrect 'CS8629 Nullable value type may be null' on implicitly-cast operand of lifted operator #39361

@jnm2

Description

@jnm2

Version Used: New in VS 16.4p2, not present in 16.4p1 or 16.3.5

No warning should be shown because the operator is lifted and therefore expects nulls:

#nullable enable

struct Foo
{
    public static implicit operator DateTime?(Foo? value) => default;

    bool M(Foo? x, DateTime y)
    {
        // CS8629 Nullable value type may be null.
        //     ↓
        return x == y;
    }
}

The other operators also trigger this bug.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions