[Mono-bugs] [Bug 58563][Wis] New - Generics compiler throws NullReferenceException when trying to compile code
bugzilla-daemon@bugzilla.ximian.com
bugzilla-daemon@bugzilla.ximian.com
Sun, 16 May 2004 00:18:15 -0400 (EDT)
Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.
Changed by cyrusn@microsoft.com.
http://bugzilla.ximian.com/show_bug.cgi?id=58563
--- shadow/58563 2004-05-16 00:18:15.000000000 -0400
+++ shadow/58563.tmp.23218 2004-05-16 00:18:15.000000000 -0400
@@ -0,0 +1,97 @@
+Bug#: 58563
+Product: Mono: Compilers
+Version: unspecified
+OS:
+OS Details: 10.3
+Status: NEW
+Resolution:
+Severity:
+Priority: Wishlist
+Component: C#
+AssignedTo: mono-bugs@ximian.com
+ReportedBy: cyrusn@microsoft.com
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: Generics compiler throws NullReferenceException when trying to compile code
+
+Please fill in this template when reporting a bug, unless you know what you
+are doing.
+Description of Problem:
+NullReferenceException thrown when trying to compile code with anonymous
+delegates
+
+Specifically:
+cyrusn@Foo ~> /opt/local/bin/gmcs foo.cs
+Mono C# Compiler 0.91.0.0 for Generics
+System.NullReferenceException: Object reference not set to an instance of
+an object
+in <0x14828> Mono.CSharp.CSharpParser:yyparse (Mono.CSharp.yyParser.yyInput)
+in <0x000b4> Mono.CSharp.CSharpParser:parse ()
+
+foo.cs(32) error CS8025: Parsing error
+Compilation failed: 1 error(s), 0 warnings
+
+
+
+Steps to reproduce the problem:
+1. Try to compile the code included below
+
+Actual Results:
+Exception thrown
+
+Expected Results:
+Code should compile properly
+
+How often does this happen?
+Every time
+
+Additional Information:
+
+delegate A Creator<A>();
+
+interface IStream<A>
+{
+ A First { get; }
+ Creator<IStream<A>> GetRest { get; }
+
+ Creator<IStream<A>> Drop(int elements);
+ Creator<IStream<A>> Take(int elements);
+ Creator<IStream<A>> Reverse();
+ Creator<IStream<A>> Append(Creator<IStream<A>> stream);
+}
+
+class Empty<A> : Structure<A>, IStream<A>
+{
+ public static readonly IStream<A> Instance = new Empty<A>();
+ private Empty() {}
+
+ public A First {
+ get {
+ throw new NotSupportedException();
+ }
+ }
+
+ public Creator<IStream<A>> GetRest {
+ get {
+ throw new NotSupportedException();
+ }
+ }
+
+ public Creator<IStream<A>> Drop(int elements) {
+ return delegate { return this; }; //<-- this code causes the crash
+ }
+
+ public Creator<IStream<A>> Take(int elements) {
+ return delegate { return this; };
+ }
+
+ public Creator<IStream<A>> Reverse() {
+ return delegate { return this; };
+ }
+
+ public Creator<IStream<A>> Append(Creator<IStream<A>> stream) {
+ return stream;
+ }
+}