Bug 8383

Summary: The mono MCS compiler is confused by matching parameter / variable name and type name
Product: [Mono] Compilers Reporter: Brett van Swelm <bswelm>
Component: C#Assignee: Marek Safar <masafa>
Status: RESOLVED FIXED    
Severity: normal CC: mauzik, 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:44:06 UTC
The mono MCS compiler is confused by matching parameter / variable name and
type name, but MS CSC is not.

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:

===== TypeHiding.cs =====
using System;

public class Outer {
    public enum Inner { ONE, TWO }
    public Inner myInner;
}

public class TypeHiding {
    public static bool Test(Outer Outer) {
        return Outer.myInner == Outer.Inner.ONE;    
    }

    public static void Main(String[] args) {
        Test(new Outer());
    }
}
===== end =====

Note the type name and parameter name are the same in the definition of method
Test. This appears to confuse mono.

$ csc TypeHiding.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 TypeHiding.cs
TypeHiding.cs(10,39): error CS0572: `Inner': cannot reference a type through an
expression; try `Outer.Inner' instead
Compilation failed: 1 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-15 11:02:56 UTC
Fixed in master