Bug 29691

Summary: Compiler error for read-only auto-properties with certain names
Product: [Mono] Compilers Reporter: Philippe Leybaert <philippe>
Component: C#Assignee: Marek Safar <masafa>
Status: RESOLVED FIXED    
Severity: normal CC: jahmai, mono-bugs+mono, philippe, yk000123
Priority: ---    
Version: unspecified   
Target Milestone: ---   
Hardware: Macintosh   
OS: Mac OS   
Tags: Is this bug a regression?: ---
Last known good build:

Description Philippe Leybaert 2015-05-03 22:47:14 UTC
The following doesn't compile in Xamarin Studio 5.9 (Mono 4.0.0 C# compiler):

    public class MyClass
    {
        Type Type { get; } // compiler error 1

        public MyClass()
        {
            Type = typeof(string); // compiler error 2
        }
    }

Two compiler errors:

error 1: error CS0118: `System.Type' is a `type' but a `variable' was expected
error 2: error CS0131: The left-hand side of an assignment must be a variable, a property or an indexer

The code compiles fine in VS2015RC

However, the following compiles fine in Xamarin Studio:

    public class MyClass
    {
        Type Type { get; set; } // Adding a setter makes it work

        public MyClass()
        {
            Type = typeof(string);
        }
    }

This also compiles fine:

    public class MyClass
    {
        Type Type1 { get; } // changing the name to Type1 makes it work

        public MyClass()
        {
            Type1 = typeof(string);
        }
    }
Comment 1 Marek Safar 2015-05-04 12:32:19 UTC
Fixed in master
Comment 2 Marek Safar 2015-05-26 05:47:08 UTC
*** Bug 30419 has been marked as a duplicate of this bug. ***
Comment 3 Jahmai 2015-08-26 01:42:49 UTC
What release will this fix be in?
Comment 4 Marek Safar 2015-08-26 08:58:45 UTC
The fix is available in Mono 4.2
Comment 5 Jahmai 2015-08-26 09:03:02 UTC
When will that be released? I checked Beta and Alpha channels and they are both 4.0.x.
Comment 6 Jahmai 2015-08-26 09:09:29 UTC
Sorry, I should be more specific. When will this fix (and the other C# 6 language feature bugs) be available in Xamarin.iOS and Xamarin.Android.