C# compiler bug? Object initializer syntax used for write-only property in Expression makes csc crash

只愿长相守 提交于 2019-12-02 18:59:24

I'm afraid I'm not Eric Lippert (Oh, but could I be so dashing...), but as a former Visual Studio languages guy who can still search the sources, I can say two things about this:

  1. Any time you see something that starts with "Internal Compiler Error" you have most definitely found a bug. That's what that error exists for, whether it's the C#, VB or C++ compiler. It's the "Oh, s**t, something just went really unexpectedly wrong!" throw-up-our-hands-and-bail-out error.

  2. Beyond that, this is definitely a bug in the C# compiler that should be reported. The code that's crashing is assuming that when you're doing an initializer on a property that there's a getter it can look at and, hey, guess what? In this case, there isn't. Oddly enough, if I change the type being constructed to some type "C" instead of "object", I don't get the crash, so I'm guessing it's a failure further up the stack (i.e. the code never should have gotten down to the point where it was looking for the property getter).

Hope this helps.

Wicked Coder

This is what I found online related to the error,

Posted by Microsoft on 3/9/2010 at 10:58 AM

Thanks everyone for the reports. I believe that this issue has been fixed post-RC. The problem is that the C# compiler is crashing as it is tries to report an error or warning. In several cases we have seen the warning being reported is that the LIB environment variable contains an invalid path. To avoid the crash, check that your LIB environment variable contains valid paths.

Regards,

Ed Maurer Development Manager, VB and C# compilers

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!