Attempting to StartCoroutine in a Coroutine crashes

I am trying to start a coroutine inside of another coroutine. However, I find that StartCoroutine() crashes inside of any coroutine with a NullReferenceException. In the case of the C# code below, the StartCoroutine() call in Coroutine1() is the culprit.

using UnityEngine;
using System.Collections;

public class NewBehaviourScript : MonoBehaviour {

	// Use this for initialization
	void Start () {
	   StartCoroutine("Coroutine1");
	}
	
	IEnumerator Coroutine1() {
	   StartCoroutine("Coroutine2");
	   yield return null;
    }
    
    IEnumerator Coroutine2() {
        Debug.Log("Coroutine2 started.");
        yield return null;
    }
}

Is there another approach to achieving this behavior? I certainly could write a class that would be sure to flatten out the nested coroutines – but the timing of the coroutines would be different then the ideal result from the above example.

Also, related question – Is there any way to make new YieldInstructions?

This bug has been fixed for 1.2.2. And is also in the recently released beta. You might want to check that out.

You can chain coroutines which is basically the same.

function DoSomething ()
{
   // Loop 5 times and wait one second every time.
   for (var i=0;i<5;i++)
   {  
      yield WaitForSeconds (1.0)
   }
}

function Start ()
{
  yield StartCoroutine ("WaitForSomething");
  
  // Time.time will now be 5 seconds
  print (Time.time);
}