Skip to content

Commit 9f72ec4

Browse files
committed
[MERGE #6216 @MikeHolman] fix bug where try block swallows yield
Merge pull request #6216 from MikeHolman:awaitbug If yield happened within a try block, the yield was being swallowed and immediately continued to the ResumeYield, which is a functional issue and also causes us to not set the ResumeYieldData. Fixes #6203
2 parents 9240377 + f32fdea commit 9f72ec4

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

lib/Runtime/Language/InterpreterLoop.inl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,7 @@ SWAP_BP_FOR_OPCODE:
307307
#ifndef INTERPRETER_ASMJS
308308
case INTERPRETER_OPCODE::Yield:
309309
{
310+
this->retOffset = m_reader.GetCurrentOffset();
310311
m_reader.Reg2_Small(ip);
311312
return GetReg(GetFunctionBody()->GetYieldRegister());
312313
}

lib/Runtime/Language/InterpreterStackFrame.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1986,6 +1986,8 @@ namespace Js
19861986
// The debugger relies on comparing stack addresses of frames to decide when a step_out is complete so
19871987
// give the InterpreterStackFrame a legit enough stack address to make this comparison work.
19881988
newInstance->m_stackAddress = reinterpret_cast<DWORD_PTR>(&generator);
1989+
1990+
newInstance->retOffset = 0;
19891991
}
19901992
else
19911993
{

test/es7/misc_bugs.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,19 @@ var tests = [
2626
}`); });
2727
}
2828
},
29+
{
30+
name: "Await in class body should not crash",
31+
body: function () {
32+
async function trigger(a=class b{
33+
[a = class b{
34+
[await 0](){}
35+
}](){}
36+
}) {
37+
}
38+
39+
trigger();
40+
}
41+
},
2942

3043
];
3144

0 commit comments

Comments
 (0)