المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Why no compiler warning in this code?



C# Programming
05-22-2012, 09:43 AM
So a guy on my team accidentally left out a "return" statement in the following code:

public override OM.ModelObjectMessageSource CreateMessageSource(OM.ModelSolutionBase solution, OM.ModelObject item, OM.ModelObject referencedItem) { ….. TtTransitionPointer oTransitionPointer = item as TtTransitionPointer; if (oTransitionPointer != null) new TransitionPointerMessageSource(oTransitionPointer); ….. return base.CreateMessageSource(solution, item, referencedItem); }
Easily enough found and fixed as it turned out, but we both were left puzzled that this wasn't a compiler warning. What's the use case for constructing the ephemeral object TransitionPointerMessageSource? It's not assigned to anything and isn't returned.
Tom Clement
Serena Software, Inc.
www.serena.com (http://www.serena.com)

articles (http://www.codeproject.com/script/articles/list_articles.asp?userid=383127)[^ (http://www.codeproject.com/script/articles/list_articles.asp?userid=383127)]