dotnet / dotnet/csharpstandard

Lifted operators and default

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

Description

Consider:

```csharp
using System;
class C
{
// means ^default(int), not ^default(int?)
static Index? I => ^default;

// means I..default(Index), not I..default(Index?)
static Range? R => I..default;

// error CS8310: Operator '*' cannot be applied to operand 'default'
static int? K => ((int?)4) * default;
}
```

Is the apparent inconsistency justified or a “feature” of a particular implementation?

The above example is from this [discussion](https://github.com/dotnet/csharpstandard/pull/1369/files#r2240774346) which ends with “Defer to a new issue”.

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.