Skip to content

3.4.0 Compiler Toolset does not allow comparing to "default" #38643

@pranavkm

Description

@pranavkm

Version Used:
Microsoft.Net.Compilers.Toolset v3.4.0-beta1-19456-03

Steps to Reproduce:

  1. Create a new console app with
class Program
{
    static void Main(string[] args)
    {
        var x = new object();
        if (x != default)
        {
            Console.WriteLine("Hello world");
        }
    }
}
  1. Reference the 3.4.0 toolset package
 <ItemGroup>
    <PackageReference Include="Microsoft.Net.Compilers.Toolset"
        Version="3.4.0-beta1-19456-03"
        PrivateAssets="all"/>
  </ItemGroup>
  1. Compile and see the failure

Program.cs(10,17): error CS0019: Operator '!=' cannot be applied to operands of type 'object' and 'default'

This compiles using Microsoft (R) Visual C# Compiler version 3.4.0-beta1-19417-02 (64f75cda) that's shipped with a SDK, but not using Microsoft (R) Visual C# Compiler version 3.4.0-beta1-19456-03 (3c865821)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

Active/Investigating

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions