Added testcase for a bug

--HG--
branch : trunk
diff --git a/jinja2/compiler.py b/jinja2/compiler.py
index 6b9c786..36f55a9 100644
--- a/jinja2/compiler.py
+++ b/jinja2/compiler.py
@@ -595,7 +595,9 @@
         # variables that are undeclared (accessed before declaration) and
         # declared locally *and* part of an outside scope raise a template
         # assertion error. Reason: we can't generate reasonable code from
-        # it without aliasing all the variables.  XXX: alias them ^^
+        # it without aliasing all the variables.
+        # this could be fixed in Python 3 where we have the nonlocal
+        # keyword or if we switch to bytecode generation
         overriden_closure_vars = (
             func_frame.identifiers.undeclared &
             func_frame.identifiers.declared &
diff --git a/tests/test_old_bugs.py b/tests/test_old_bugs.py
index a30c909..687d962 100644
--- a/tests/test_old_bugs.py
+++ b/tests/test_old_bugs.py
@@ -33,3 +33,23 @@
 def test_urlize_filter_escaping(env):
     tmpl = env.from_string('{{ "http://www.example.org/<foo"|urlize }}')
     assert tmpl.render() == '<a href="http://www.example.org/&lt;foo">http://www.example.org/&lt;foo</a>'
+
+
+def test_loop_call_loop(env):
+    tmpl = env.from_string('''
+
+    {% macro test() %}
+        {{ caller() }}
+    {% endmacro %}
+
+    {% for num1 in range(5) %}
+        {% call test() %}
+            {% for num2 in range(10) %}
+                {{ loop.index }}
+            {% endfor %}
+        {% endcall %}
+    {% endfor %}
+
+    ''')
+
+    assert tmpl.render() == ''