Skip to content

Commit feca4d6

Browse files
committed
Fix yielding value from throw
1 parent 4e3c20e commit feca4d6

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

graalpython/com.oracle.graal.python.test/testData/goldenFiles/CompilerTests/testCoroutine.co

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ Flags: CO_COROUTINE
1010
000022 2 GET_AWAITABLE
1111
000022 3 LOAD_NONE
1212
000022 >> 4 SEND 10 (to 14)
13-
000022 6 YIELD_VALUE
13+
000022 >> 6 YIELD_VALUE
1414
000022 7 RESUME_YIELD
1515
000022 8 JUMP_BACKWARD 4 (to 4)
1616
000022 10 THROW 4 (exc handler 7 - 10; stack: 1)
17-
000022 12 JUMP_BACKWARD 8 (to 4)
17+
000022 12 JUMP_BACKWARD 6 (to 6)
1818
000022 >> 14 POP_TOP
1919
000000 15 LOAD_NONE
2020
000000 16 RETURN_VALUE

graalpython/com.oracle.graal.python.test/testData/goldenFiles/CompilerTests/testYieldFrom.co

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ Flags: CO_GENERATOR
1010
000016 2 GET_ITER
1111
000016 3 LOAD_NONE
1212
000016 >> 4 SEND 10 (to 14)
13-
000016 6 YIELD_VALUE
13+
000016 >> 6 YIELD_VALUE
1414
000016 7 RESUME_YIELD
1515
000016 8 JUMP_BACKWARD 4 (to 4)
1616
000016 10 THROW 4 (exc handler 7 - 10; stack: 1)
17-
000016 12 JUMP_BACKWARD 8 (to 4)
17+
000016 12 JUMP_BACKWARD 6 (to 6)
1818
000016 >> 14 POP_TOP
1919
000000 15 LOAD_NONE
2020
000000 16 RETURN_VALUE

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/compiler/Compiler.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1453,11 +1453,13 @@ public Void visit(ExprTy.YieldFrom node) {
14531453

14541454
private void addYieldFrom() {
14551455
Block start = new Block();
1456+
Block yield = new Block();
14561457
Block resume = new Block();
14571458
Block exit = new Block();
14581459
Block exceptionHandler = new Block();
14591460
unit.useNextBlock(start);
14601461
addOp(SEND, exit);
1462+
unit.useNextBlock(yield);
14611463
addOp(YIELD_VALUE);
14621464
unit.pushBlock(new BlockInfo.TryExcept(resume, exceptionHandler));
14631465
unit.useNextBlock(resume);
@@ -1466,7 +1468,7 @@ private void addYieldFrom() {
14661468
unit.popBlock();
14671469
unit.useNextBlock(exceptionHandler);
14681470
addOp(THROW, exit);
1469-
addOp(JUMP_BACKWARD, start);
1471+
addOp(JUMP_BACKWARD, yield);
14701472
unit.useNextBlock(exit);
14711473
}
14721474

0 commit comments

Comments
 (0)