PrimeIntellect/SWE-rebench-V2-Filtered-Easy-Verified huggingface dataset:
Repository: twigphp/Twig (php)
Issue: In version 3.15.0, when accessing SplObjectStorage by index (object), an error is generated
```
{% for q in sections[s] %}
```
where section is SplObjectStorage 
and s is a object
Raise error  An exception has been thrown during the rendering of a template ("Object of class App\Attempt\Section could not be converted to string").

Pull request description: Fix ArrayAccess with objects as keys
fixes #4476
The bug was introduced in 3.15 via https://github.com/twigphp/Twig/pull/4425#discussion_r1869120001

Patch:
diff --git a/src/Extension/CoreExtension.php b/src/Extension/CoreExtension.php
index a693d947..567c7e67 100644
--- a/src/Extension/CoreExtension.php
+++ b/src/Extension/CoreExtension.php
@@ -1644,7 +1644,7 @@ final class CoreExtension extends AbstractExtension
 
         // array
         if (Template::METHOD_CALL !== $type) {
-            $arrayItem = \is_bool($item) || \is_float($item) ? (int) $item : $item = (string) $item;
+            $arrayItem = \is_bool($item) || \is_float($item) ? (int) $item : $item;
 
             if ($sandboxed && $object instanceof \ArrayAccess && !\in_array($object::class, self::ARRAY_LIKE_CLASSES, true)) {
                 try {


Test patch:
diff --git a/tests/Fixtures/expressions/array.test b/tests/Fixtures/expressions/array.test
index 1de76e93..7d1c3b0a 100644
--- a/tests/Fixtures/expressions/array.test
+++ b/tests/Fixtures/expressions/array.test
@@ -42,12 +42,19 @@ Twig supports array notation
 {# ArrayAccess #}
 {{ array_access['a'] }}
 
+{# ObjectStorage #}
+{{ object_storage[object] }}
+{{ object_storage[object_storage]|default('bar') }}
+
 {# array that does not exist #}
 {{ does_not_exist[0]|default('ok') }}
 {{ does_not_exist[0].does_not_exist_either|default('ok') }}
 {{ does_not_exist[0]['does_not_exist_either']|default('ok') }}
 --DATA--
-return ['bar' => 'bar', 'foo' => ['bar' => 'bar'], 'array_access' => new \ArrayObject(['a' => 'b'])]
+$objectStorage = new SplObjectStorage();
+$object = new stdClass();
+$objectStorage[$object] = 'foo';
+return ['bar' => 'bar', 'foo' => ['bar' => 'bar'], 'array_access' => new \ArrayObject(['a' => 'b']), 'object_storage' => $objectStorage, 'object' => $object]
 --EXPECT--
 1,2
 foo,bar
@@ -71,11 +78,14 @@ a,b,c,d,e
 
 b
 
+foo
+bar
+
 ok
 ok
 ok
 --DATA--
-return ['bar' => 'bar', 'foo' => ['bar' => 'bar'], 'array_access' => new \ArrayObject(['a' =>  'b'])]
+return ['bar' => 'bar', 'foo' => ['bar' => 'bar'], 'array_access' => new \ArrayObject(['a' =>  'b']), 'object' => new stdClass()]
 --CONFIG--
 return ['strict_variables' => false]
 --EXPECT--
@@ -101,6 +111,9 @@ a,b,c,d,e
 
 b
 
+
+bar
+
 ok
 ok
 ok