C# 4.0 编译器崩溃
此代码示例无法编译。有什么解决办法吗?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
using church = Func<dynamic, dynamic, dynamic>;
class Program
{
static void Main(string[] args)
{
church True = (a, b) => a;
church False = (a, b) => b;
Func<church, church, church> And = (x, y) => x(y(True, False), False);
}
}
}
错误 6 内部编译器错误(地址 5476A4CC 处为 0xc0000005):可能的罪魁祸首是“EMITIL”。编译器中发生内部错误。要解决此问题,请尝试简化或更改下列位置附近的程序。列表顶部的位置更接近发生内部错误的点。可以使用 /errorreport 选项向 Microsoft 报告此类错误。测试应用程序
This code sample is not able to be compiled. Any work arounds out there?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
using church = Func<dynamic, dynamic, dynamic>;
class Program
{
static void Main(string[] args)
{
church True = (a, b) => a;
church False = (a, b) => b;
Func<church, church, church> And = (x, y) => x(y(True, False), False);
}
}
}
Error 6 Internal Compiler Error (0xc0000005 at address 5476A4CC): likely culprit is 'EMITIL'. An internal error has occurred in the compiler. To work around this problem, try simplifying or changing the program near the locations listed below. Locations at the top of the list are closer to the point at which the internal error occurred. Errors such as this can be reported to Microsoft by using the /errorreport option. TestApplication
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

发布评论
评论(4)
我使用 VS2010 (WinXP 64) 重现了崩溃。
两种解决方法:
1. 不要使用 using
别名
以下代码可以在 VS2010 上干净地编译:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Func<dynamic, dynamic, dynamic> True = (a, b) => a;
Func<dynamic, dynamic, dynamic> False = (a, b) => b;
Func<Func<dynamic, dynamic, dynamic>,
Func<dynamic, dynamic, dynamic>,
Func<dynamic, dynamic, dynamic> > And
= (x, y) => x(y(True, False), False);
}
}
}
2. 使用 Mono 编译器
Mono 2.10 编译器 (dmcs) 没有问题。
[mono] /tmp @ dmcs test.cs
test.cs(18,42): warning CS0219: The variable `And' is assigned but its value is never used
Compilation succeeded - 1 warning(s)
[mono] /tmp @ ./test.exe
[mono] /tmp @
这是在linux上测试的。
- 您可以在 Windows .NET 上运行使用 mono 创建的二进制文件。
- Mono 编译器附带安装程序 MSI,也可以在 Windows 上运行。
编辑:我现在已经成功地重现了它,并且我有一个潜在的解决方法。
这有效:
csc Test.cs
这不起作用:
csc /debug+ Test.cs
所以看起来这是调试信息的问题。如果您在特定场景中可以没有它,那么您就可以开始...
编辑:我刚刚测试过,这也发生在 /debug:pdbonly
中...
编辑:以防万一有人想知道,我会联系埃里克·利珀特(Eric Lippert)询问此事。
编辑:这是我现在发现的最小重现:
using church = System.Func<dynamic>;
class Program
{
static void Main() {}
}
这是另一个解决方法:不要使用 Func
,使用良好的旧委托类型。
public delegate dynamic Church(dynamic x, dynamic y);
class Program {
static void Main(string[] args) {
Church True = (a, b) => a;
Church False = (a, b) => b;
Func<Church, Church, Church> And = (x, y) => x(y(True, False), False);
}
}
这还有一个好处,即 Church 可以在任何地方定义,而不仅仅是使用别名作为每个文件。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
显然这是一个编译器错误。
我向我们的一位测试人员提到了这一点,他说:
对于错误我们深表歉意,并感谢您提请我们注意此问题。
Clearly that is a compiler bug.
I mentioned this to one of our testers and he says:
Apologies for the error, and thanks for bringing this to our attention.