Bug 8384

Summary: Mono MCS fails to parse null coalescing operator when used as a conditional
Product: [Mono] Compilers Reporter: Brett van Swelm <bswelm>
Component: C#Assignee: Marek Safar <masafa>
Status: RESOLVED FIXED    
Severity: normal CC: mono-bugs+mono
Priority: ---    
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows   
Tags: Is this bug a regression?: ---
Last known good build:

Description Brett van Swelm 2012-11-13 18:51:50 UTC
Mono MCS fails to parse null coalescing operator when used as a conditional.

With "D:\Applications\Mono-2.11.4\bin" and
"C:\Windows\Microsoft.NET\Framework\v4.0.30319" in the path on my Windows 7
machine:

===== NullOperand.cs =====
using System;

public class NullOperator {
    public static void Test(object param) {
        if (param as bool? ?? false) {} else {}
    }
    public static void Main(String[] args) {}
} 
===== end =====

$ csc NullOperator.cs
Microsoft (R) Visual C# Compiler version 4.0.30319.17929
for Microsoft (R) .NET Framework 4.5
Copyright (C) Microsoft Corporation. All rights reserved.

$ mcs NullOperator.cs
NullOperator.cs(5,27): error CS1525: Unexpected symbol `??'
NullOperator.cs(5,31): error CS0201: Only assignment, call, increment,
decrement, await, and new object expressions can be used as a statement
NullOperator.cs(5,35): error CS1525: Unexpected symbol `)'
NullOperator.cs(5,40): error CS1525: Unexpected symbol `else'
Compilation failed: 4 error(s), 0 warnings

Thanks,

Brett van Swelm | Senior Engineer
Coverity | 185 Berry Street | Suite 6500, Lobby 3 | San Francisco, CA 94107
The Leader in Development Testing
Read our profile in Forbes, Coverity Gets Code Right 25% Faster
Comment 1 Marek Safar 2012-11-16 06:34:02 UTC
Fixed in master