Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CSC crashes (instead of emitting error CS0154) when dotting off a setter-only property of type dynamic #9945

Closed
ljw1004 opened this issue Mar 21, 2016 · 1 comment
Assignees
Labels
Area-Compilers Bug Tenet-Compatibility Violation of forwards/backwards compatibility in a design-time piece.
Milestone

Comments

@ljw1004
Copy link
Contributor

ljw1004 commented Mar 21, 2016

Version Used:
VS2015 Update 2 RC

Steps to Reproduce:

Create a console app with the following code, and build it:

class Program
{
    static void Main()
    {
        I i = null;
        System.Type ts = i.s.GetType();  // compile-time error CS0154
        System.Type td = i.d.GetType();  // compile-time CRASH with error code -2146232797
    }

    public interface I
    {
        string s { set; }
        dynamic d { set; }
    }
}

Expected Behavior:

Both GetType() lines should emit CS0154 "property cannot be used in this context because it lacks a get accessor"

Actual Behavior:

The second GetType() line causes a compiler crash with

@jaredpar
Copy link
Member

The crash will not reproduce with the code as written in the bug. In order to hit the crash the code needs to remove the first GetType line and leave only the following:

    static void Main()
    {
        I i = null;
        System.Type td = i.d.GetType();  // compile-time CRASH with error code -2146232797
    }

Having the first GetType line issues an error which prevents the compiler from going to code generation where the bug occurs. Once that is deleted the code does indeed throw an exception in LocalRewriter.MakePropertyAccess

@jaredpar jaredpar added the Tenet-Compatibility Violation of forwards/backwards compatibility in a design-time piece. label Mar 31, 2016
@jaredpar jaredpar assigned khyperia and unassigned cston May 9, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Compilers Bug Tenet-Compatibility Violation of forwards/backwards compatibility in a design-time piece.
Projects
None yet
Development

No branches or pull requests

5 participants