diff --git a/lib/Twig/Template.php b/lib/Twig/Template.php
index 1fe203fc0..2ead6abf8 100644
--- a/lib/Twig/Template.php
+++ b/lib/Twig/Template.php
@@ -250,7 +250,7 @@ abstract class Twig_Template implements Twig_TemplateInterface
*/
public function display(array $context, array $blocks = array())
{
- $this->displayWithErrorHandling($this->env->mergeGlobals($context), $blocks);
+ $this->displayWithErrorHandling($this->env->mergeGlobals($context), array_merge($this->blocks, $blocks));
}
/**
diff --git a/test/Twig/Tests/Fixtures/tags/use/inheritance.test b/test/Twig/Tests/Fixtures/tags/use/inheritance.test
new file mode 100644
index 000000000..6368b08de
--- /dev/null
+++ b/test/Twig/Tests/Fixtures/tags/use/inheritance.test
@@ -0,0 +1,25 @@
+--TEST--
+"use" tag
+--TEMPLATE--
+{% use "parent.twig" %}
+
+{{ block('container') }}
+--TEMPLATE(parent.twig)--
+{% use "ancestor.twig" %}
+
+{% block sub_container %}
+
overriden sub_container
+{% endblock %}
+--TEMPLATE(ancestor.twig)--
+{% block container %}
+ {{ block('sub_container') }}
+{% endblock %}
+
+{% block sub_container %}
+ sub_container
+{% endblock %}
+--DATA--
+return array()
+--EXPECT--
+ overriden sub_container
+
diff --git a/test/Twig/Tests/Fixtures/tags/use/inheritance2.test b/test/Twig/Tests/Fixtures/tags/use/inheritance2.test
new file mode 100644
index 000000000..114e3015e
--- /dev/null
+++ b/test/Twig/Tests/Fixtures/tags/use/inheritance2.test
@@ -0,0 +1,24 @@
+--TEST--
+"use" tag
+--TEMPLATE--
+{% use "ancestor.twig" %}
+{% use "parent.twig" %}
+
+{{ block('container') }}
+--TEMPLATE(parent.twig)--
+{% block sub_container %}
+ overriden sub_container
+{% endblock %}
+--TEMPLATE(ancestor.twig)--
+{% block container %}
+ {{ block('sub_container') }}
+{% endblock %}
+
+{% block sub_container %}
+ sub_container
+{% endblock %}
+--DATA--
+return array()
+--EXPECT--
+ overriden sub_container
+
diff --git a/test/Twig/Tests/Fixtures/tags/use/parent_block.test b/test/Twig/Tests/Fixtures/tags/use/parent_block.test
new file mode 100644
index 000000000..59db23d95
--- /dev/null
+++ b/test/Twig/Tests/Fixtures/tags/use/parent_block.test
@@ -0,0 +1,24 @@
+--TEST--
+"use" tag
+--TEMPLATE--
+{% use 'file2.html.twig' with foobar as base_base_foobar %}
+{% block foobar %}
+ {{- block('base_base_foobar') -}}
+ Content of block (second override)
+{% endblock foobar %}
+--TEMPLATE(file2.html.twig)--
+{% use 'file1.html.twig' with foobar as base_foobar %}
+{% block foobar %}
+ {{- block('base_foobar') -}}
+ Content of block (first override)
+{% endblock foobar %}
+--TEMPLATE(file1.html.twig)--
+{% block foobar -%}
+ Content of block
+{% endblock foobar %}
+--DATA--
+return array()
+--EXPECT--
+Content of block
+Content of block (first override)
+Content of block (second override)
diff --git a/test/Twig/Tests/Fixtures/tags/use/parent_block2.test b/test/Twig/Tests/Fixtures/tags/use/parent_block2.test
new file mode 100644
index 000000000..d3f302df0
--- /dev/null
+++ b/test/Twig/Tests/Fixtures/tags/use/parent_block2.test
@@ -0,0 +1,24 @@
+--TEST--
+"use" tag
+--TEMPLATE--
+{% use 'file2.html.twig'%}
+{% block foobar %}
+ {{- parent() -}}
+ Content of block (second override)
+{% endblock foobar %}
+--TEMPLATE(file2.html.twig)--
+{% use 'file1.html.twig' %}
+{% block foobar %}
+ {{- parent() -}}
+ Content of block (first override)
+{% endblock foobar %}
+--TEMPLATE(file1.html.twig)--
+{% block foobar -%}
+ Content of block
+{% endblock foobar %}
+--DATA--
+return array()
+--EXPECT--
+Content of block
+Content of block (first override)
+Content of block (second override)
diff --git a/test/Twig/Tests/Fixtures/tags/use/parent_block3.test b/test/Twig/Tests/Fixtures/tags/use/parent_block3.test
new file mode 100644
index 000000000..95b55a469
--- /dev/null
+++ b/test/Twig/Tests/Fixtures/tags/use/parent_block3.test
@@ -0,0 +1,38 @@
+--TEST--
+"use" tag
+--TEMPLATE--
+{% use 'file2.html.twig' %}
+{% use 'file1.html.twig' with foo %}
+{% block foo %}
+ {{- parent() -}}
+ Content of foo (second override)
+{% endblock foo %}
+{% block bar %}
+ {{- parent() -}}
+ Content of bar (second override)
+{% endblock bar %}
+--TEMPLATE(file2.html.twig)--
+{% use 'file1.html.twig' %}
+{% block foo %}
+ {{- parent() -}}
+ Content of foo (first override)
+{% endblock foo %}
+{% block bar %}
+ {{- parent() -}}
+ Content of bar (first override)
+{% endblock bar %}
+--TEMPLATE(file1.html.twig)--
+{% block foo -%}
+ Content of foo
+{% endblock foo %}
+{% block bar -%}
+ Content of bar
+{% endblock bar %}
+--DATA--
+return array()
+--EXPECT--
+Content of foo
+Content of foo (first override)
+Content of foo (second override)
+Content of bar
+Content of bar (second override)