dotnet / dotnet/csharpstandard

Half-Lifted Conversions

Open
#191 0 comments 0 reactions 0 assignees View on GitHub
type: bug
Dominant language
C#
Stars
815
Forks
99
Avg merge
1d 14h
Merged PRs (30d)
16

Description

Given

```csharp
public struct S1
{
    public static implicit operator C(S1 s)
    {
        return new C();
    }
    public static implicit operator S2?(S1 s)
    {
        return null;
    }
}

public struct S2 { }

public class C { }
```

Existing compilers allow the following

```csharp
        Func func1 = x => x;

        Func func2 = x => x;
```

But neither is justified by the specification.  It would be nice if the specification were revised to allow these.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.