Repository: quarkusio/quarkus
Issue: Problem with Qute context using for and each blocks

**Describe the bug**
Using `for` and `each` blocks, when accessing an existing key, I think it shouldn't use the `data` context no?

Reproducer code:
```Java
    @Test
    void quteTest() throws IOException {
        final HashMap<String, Object> dep1 = new HashMap<>();
        dep1.put("version", "1.0");

        final HashMap<String, Object> data = new HashMap<>();
        data.put("dependencies", Arrays.asList(dep1, new HashMap<>()));
        data.put("version", "hellllllo");
        final String result = Engine.builder().addDefaults().build().parse("{#for dep in dependencies}\\n{#if dep.version}<version>{dep.version}</version>\\n{/if}\\n{/for}").render(data);
        Assertions.assertThat(result).doesNotContain("hellllllo");
    }
```

Maybe this is an expected behavior with `it` using a `each` block, but with `for` assigned to `dep` in the example it doesn't make sense at all.

Changed files:
independent-projects/qute/core/src/main/java/io/quarkus/qute/EvaluatorImpl.java
independent-projects/qute/core/src/test/java/io/quarkus/qute/LoopSectionTest.java

diff --git a/independent-projects/qute/core/src/main/java/io/quarkus/qute/EvaluatorImpl.java b/independent-projects/qute/core/src/main/java/io/quarkus/qute/EvaluatorImpl.java
index e2152b2eb37..b0488e968ad 100644
--- a/independent-projects/qute/core/src/main/java/io/quarkus/qute/EvaluatorImpl.java
+++ b/independent-projects/qute/core/src/main/java/io/quarkus/qute/EvaluatorImpl.java
@@ -73,14 +73,9 @@ private CompletionStage<Object> resolveReference(boolean tryParent, Object ref,
             // The last part - no need to compose
             return resolve(evalContext, resolvers.iterator());
         } else {
+            // Next part - no need to try the parent context/outer scope
             return resolve(evalContext, resolvers.iterator())
-                    .thenCompose(r -> {
-                        if (parts.hasNext()) {
-                            return resolveReference(tryParent, r, parts, resolutionContext);
-                        } else {
-                            return CompletableFuture.completedFuture(r);
-                        }
-                    });
+                    .thenCompose(r -> resolveReference(false, r, parts, resolutionContext));
         }
     }
 
diff --git a/independent-projects/qute/core/src/test/java/io/quarkus/qute/LoopSectionTest.java b/independent-projects/qute/core/src/test/java/io/quarkus/qute/LoopSectionTest.java
index 639e766b38f..e07ce14898a 100644
--- a/independent-projects/qute/core/src/test/java/io/quarkus/qute/LoopSectionTest.java
+++ b/independent-projects/qute/core/src/test/java/io/quarkus/qute/LoopSectionTest.java
@@ -1,6 +1,7 @@
 package io.quarkus.qute;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 import static org.junit.jupiter.api.Assertions.fail;
 
@@ -147,4 +148,26 @@ public void testNoniterable() {
         }
     }
 
+    @Test
+    void testScope() {
+        final HashMap<String, Object> dep1 = new HashMap<>();
+        dep1.put("version", "1.0");
+        final HashMap<String, Object> data = new HashMap<>();
+        data.put("dependencies", Arrays.asList(dep1, new HashMap<>()));
+        data.put("version", "hellllllo");
+        Engine engine = Engine.builder().addDefaults().build();
+        String result = engine.parse("{#for dep in dependencies}{#if dep.version}<version>{dep.version}</version>{/if}{/for}")
+                .render(data);
+        assertFalse(result.contains("hellllllo"), result);
+        result = engine.parse("{#for dep in dependencies}{#if dep.version}<version>{version}</version>{/if}{/for}")
+                .render(data);
+        assertTrue(result.contains("hellllllo"), result);
+        result = engine.parse("{#each dependencies}{#if it.version}<version>{it.version}</version>{/if}{/each}")
+                .render(data);
+        assertFalse(result.contains("hellllllo"), result);
+        result = engine.parse("{#each dependencies}{#if it.version}<version>{version}</version>{/if}{/each}")
+                .render(data);
+        assertTrue(result.contains("hellllllo"), result);
+    }
+
 }