Bug 34753

Summary: Mono C# compiler incorrectly outputs CS0019 with reference equality to (null)
Product: [Mono] Compilers Reporter: Stephen Darnell <darnellium>
Component: C#Assignee: Marek Safar <masafa>
Severity: normal CC: mono-bugs+mono
Priority: ---    
Version: 4.0.0   
Target Milestone: ---   
Hardware: Macintosh   
OS: Mac OS   
Tags: Is this bug a regression?: ---
Last known good build:
Attachments: Test file showing problem.
Attachment with text/plain mime format

Description Stephen Darnell 2015-10-11 12:13:51 UTC
Created attachment 13277 [details]
Test file showing problem.

MCS incorrectly outputs CS0019 when comparing a reference against (null) in brackets.

See the attached test file with the following lines:
    Wibble w = new Wibble();
    if (w == (null)) ...

This produces:
$ mcs test.cs
test.cs(6,9): error CS0019: Operator `==' cannot be applied to operands of type `Wibble' and `null'
Compilation failed: 1 error(s), 0 warnings

Without the brackets around the null the code compiles without any error.

Obviously this test case is the smallest example I could produce and is easily modified to compile.
But the real life situation is a bit more complicated and involves generated code so it is a little tricky to 'just remove the brackets', but if this issue could be fixed, that would be great. Thanks.

OS: Mac OS-X 10.10.5
Mono: Mono JIT compiler version 4.0.4
MCS: Mono C# compiler version
Comment 1 Stephen Darnell 2015-10-11 12:15:19 UTC
Created attachment 13278 [details]
Attachment with text/plain mime format
Comment 2 Marek Safar 2015-10-12 13:00:18 UTC
Fixed in master