This is Xamarin's bug tracking system. For product support, please use the support links listed in your Xamarin Account.
Bug 44168 - Can use non-accessible member with nameof
Summary: Can use non-accessible member with nameof
Status: RESOLVED FIXED
Alias: None
Product: Compilers
Classification: Mono
Component: C# (show other bugs)
Version: 4.4.2 (C7SR1)
Hardware: PC Linux
: --- normal
Target Milestone: ---
Assignee: Marek Safar
URL:
Depends on:
Blocks:
 
Reported: 2016-09-10 18:26 UTC by gsvick
Modified: 2016-09-16 09:01 UTC (History)
1 user (show)

See Also:
Tags:
Is this bug a regression?: ---
Last known good build:


Attachments

Description gsvick 2016-09-10 18:26:21 UTC
When compiling this code:

    using System;
     
    public class Test
    {
        public static void Main()
        {
            Console.WriteLine(nameof(A.X));
            Console.WriteLine(nameof(A.Y));  // works fine, but shouldn't
        }
    }
     
    public class A
    {
        public int X;
        private int Y {get; set;}
    }

The Roslyn compiler fails with:

> error CS0122: 'A.Y' is inaccessible due to its protection level

The mcs compiler (I have tried the latest version from the download.mono-project.com repo on Ubuntu, which is 4.4.2.0) does not report any error and the resulting program runs fine. It should instead mirror the Roslyn compiler and fail during compilation.
Comment 1 Marek Safar 2016-09-16 09:01:42 UTC
Fixed in master and Mono 4.8

Note You need to log in before you can comment on or make changes to this bug.