[Mono-bugs] [Bug 420832] New: [GMCS] Regression from 1.9, unexpected NullException thrown when creating new lists, from empty lists and yield returns.
bugzilla_noreply at novell.com
bugzilla_noreply at novell.com
Wed Aug 27 16:10:13 EDT 2008
https://bugzilla.novell.com/show_bug.cgi?id=420832
Summary: [GMCS] Regression from 1.9, unexpected NullException
thrown when creating new lists, from empty lists and
yield returns.
Product: Mono: Compilers
Version: 2.0
Platform: All
OS/Version: All
Status: NEW
Severity: Normal
Priority: P5 - None
Component: C#
AssignedTo: mono-bugs at lists.ximian.com
ReportedBy: Vernish13 at gmail.com
QAContact: mono-bugs at lists.ximian.com
Found By: ---
The following bug is present in the Mono 2.0 branch and mono trunk. The bug is
NOT present in mono 1.9.
An unexpected NullReferenceException is thrown when creating a new List<T>
twice from an empty IEnumerable<T> that was returned from another class and
used yield return.
This example works correctly using mono & csc assemblies. gmcs assemblies with
NET runtime will produce the bug.
Bug Output :
Unhandled Exception: System.NullReferenceException: Object reference not set to
an instance of an object
at MySystem+<>c__Iterator0.MoveNext () [0x00000]
at System.Collections.Generic.List`1[System.Object].AddEnumerable
(IEnumerable`1 enumerable) [0x00000]
at System.Collections.Generic.List`1[System.Object]..ctor (IEnumerable`1
collection) [0x00000]
at Test.findNearestSource (IEnumerable`1 items) [0x00000]
at Test.Main (System.String[] args) [0x00000]
Correct Output :
[TEST] Done
Code :
using System;
using System.Collections.Generic;
public class Test
{
public static void Main(String[] args)
{
MySystem mySystem = new MySystem();
TestFunction(mySystem.Items);
Console.WriteLine("[TEST] Done");
}
public static void TestFunction(IEnumerable<string> items)
{
List<string> newList;
newList = new List<string>(items);
newList = new List<string>(items);
}
}
public class MySystem
{
private List<string> _items = new List<string>();
public MySystem()
{
}
public IEnumerable<string> Items
{
get
{
foreach (string i in _items)
{
yield return i;
}
}
}
}
--
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.
More information about the mono-bugs
mailing list