Skip to content

Commit 42590c0

Browse files
committed
Bug #369: Cannot use array access on yielded values.
1 parent ad18728 commit 42590c0

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

jphp-core/src/org/develnext/jphp/core/syntax/generators/manually/SimpleExprGenerator.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1458,8 +1458,9 @@ else if (previous instanceof StaticAccessExprToken){
14581458
StringExprToken.class,
14591459
StringBuilderExprToken.class,
14601460
CallOperatorToken.class,
1461-
ArrayPushExprToken.class) ||
1462-
(previous instanceof StaticAccessExprToken)){
1461+
ArrayPushExprToken.class,
1462+
YieldExprToken.class) ||
1463+
(previous instanceof StaticAccessExprToken) || isClosedBrace(previous, SIMPLE)){
14631464
// array
14641465
current = processArrayToken(previous, current, iterator);
14651466
if (previous instanceof DynamicAccessExprToken && current instanceof ArrayGetRefExprToken){

jphp-core/tests/org/develnext/jphp/core/compiler/jvm/GeneratorsTest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,4 +218,9 @@ public void testCountError() {
218218
public void testBug262() {
219219
check("generators/bug262.php");
220220
}
221+
222+
@Test
223+
public void testBug369() {
224+
check("generators/bug369.phpt");
225+
}
221226
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
--TEST--
2+
yield can be used without a value
3+
--FILE--
4+
<?php
5+
6+
$a = function() { var_dump((yield)['a']); };
7+
$a()->send(['a' => 'pony']);
8+
9+
?>
10+
--EXPECT--
11+
string(4) "pony"

0 commit comments

Comments
 (0)