Re: ms csharp compiler bug
- From: "Alvin Bruney [MVP]" <www.lulu.com/owc>
- Date: Mon, 10 Jul 2006 19:21:59 -0400
it looks strange but i'd consider it a valid expression and so it should
compile and even produce a result. Why do you think it is a bug?
Mathematically, an empty set plus an object must evaluate to the object
right?
However, when I run the example, I get a system.string being printed out
with the code. Removing the null, I get a system.object. That to me implies
an inconsistency.
thoughts/comments?
--
________________________
Warm regards,
Alvin Bruney [MVP ASP.NET]
[Shameless Author plug]
Professional VSTO.NET - Wrox/Wiley
The O.W.C. Black Book with .NET
www.lulu.com/owc, Amazon
Blog: http://www.msmvps.com/blogs/alvin
-------------------------------------------------------
"Toby Altman" <TobyAltman@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:AE974BF3-6A1F-4B04-9284-36966D31E5AE@xxxxxxxxxxxxxxxx
I am working on a c# compiler for the DynamicMethod so I try a lot of
strange things out. I came across this one:
public void CompileBug()
{
object obj = null + new object();
Console.WriteLine(obj.GetType().ToString() );
}
// IL disasm
{
// Method begins at RVA 0x111bc
// Code size 31 (0x1f)
.maxstack 2
.locals init ([0] object obj)
IL_0000: /* 00 | */ nop
IL_0001: /* 14 | */ ldnull
IL_0002: /* 73 | (0A)000024 */ newobj instance void
[mscorlib]System.Object::.ctor()
IL_0007: /* 28 | (0A)0001D0 */ call string
[mscorlib]System.String::Concat(object,
object)
IL_000c: /* 0A | */ stloc.0
IL_000d: /* 06 | */ ldloc.0
IL_000e: /* 6F | (0A)0000B4 */ callvirt instance class
[mscorlib]System.Type [mscorlib]System.Object::GetType()
IL_0013: /* 6F | (0A)00006E */ callvirt instance string
[mscorlib]System.Object::ToString()
IL_0018: /* 28 | (0A)000028 */ call void
[mscorlib]System.Console::WriteLine(string)
IL_001d: /* 00 | */ nop
IL_001e: /* 2A | */ ret
} // end of method XXX::CompileBug
I assume this should not compile at all. If I am right in my assumption
what should the error message be ? Something like "No implicit conversion
for ..." .
Is a literal null with no context considered to be of type Object (I
thought
I saw that in ECMA 334).
.
- Follow-Ups:
- Re: ms csharp compiler bug
- From: Toby Altman
- Re: ms csharp compiler bug
- Prev by Date: Comportamiento de ListView en Pantalla
- Next by Date: Re: Automated Software Testing Tools
- Previous by thread: Comportamiento de ListView en Pantalla
- Next by thread: Re: ms csharp compiler bug
- Index(es):
Relevant Pages
|