Living on the Edge

11/7/2005 8:28:14 AM

Living on the Edge

I pinpointed the cause of my internal compiler errors while programming under C# in Visual Studio 2005. I included some of my errors in the comments of my post on Visual Studio 2005 Bugs.

Over the course of the Visual Studio beta program, I have encountered four different internal compilation errors. It appears that, as a programmer, I tend to stress test the language, not because of any overly complicated designs, but because I tend to live on the edge, forcing the compiler to do a lot more work on edge cases.

One of my bugs that I filed in the MSDN Product Feedback Center, in February involved a sealed virtual property, in which only one of the two accessors from a base class was overridden. What happened here was that the interaction of multiple special conditions was being tested.

  1. Overriding only one accessor.
  2. Sealing a virtual property, (not a simple method), with two accessors.

The internal errors that I am receiving now result from defining both a nongeneric type and a generic type of the same name. In this case, I had Tuple, Tuple<First, Second>, Tuple<First, Second, Third>. I also have a Node and a Node<A,T> in different namespaces. The compiler automatically generates special names for the generic types such as Tuple`1 and Node`2, depending on the number of type parameters used.

There is simply no reason for me to create unnecessary disambiguation work for the compiler. I could simply rename Tuple<F,S> to Pair<F,S> and Tuple<F,S,T> to Triple<F,S,T>. Making the compiler happy will ultimately make you happy.

Lesson for today: Try not to live on the edge.

Comments

 

Navigation

Categories

About

Net Undocumented is a blog about the internals of .NET including Xamarin implementations. Other topics include managed and web languages (C#, C++, Javascript), computer science theory, software engineering and software entrepreneurship.

Social Media