Skip to content

Commit fb2fe44

Browse files
authored
Merge pull request #6702 from rhuanjl/handleAsyncGenInFillScopeObj
Check for AsyncGenerator in FillScopeObject Fix bug introduced by #6456 as that made JavascriptAsyncGeneratoFunction into a sub-class of JavascriptGeneratorFunction. A check in FillScopeObject was relying on IsBaseGeneratorFunction returning true for both JavascriptGeneratorFunction and JavascriptAsyncGeneratorFunction which it was no longer doing. Instead use VarIs<JavascriptGeneratorFunction> which returns true for JavascriptGeneratorFunction, JavascriptAsyncGeneratorFunction and JavascriptAsyncFunction. Also - minor can use UnsafeVarTo on the line after as the type check has just been done. Fix: #6682
2 parents c7f192a + 862372e commit fb2fe44

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

lib/Runtime/Language/JavascriptOperators.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7497,8 +7497,8 @@ using namespace Js;
74977497
DynamicType* newType = nullptr;
74987498
if (nonSimpleParamList)
74997499
{
7500-
bool skipLetAttrForArguments = ((JavascriptGeneratorFunction::IsBaseGeneratorFunction(funcCallee) || VarIs<JavascriptAsyncFunction>(funcCallee)) ?
7501-
VarTo<JavascriptGeneratorFunction>(funcCallee)->GetGeneratorVirtualScriptFunction()->GetFunctionBody()->HasReferenceableBuiltInArguments()
7500+
bool skipLetAttrForArguments = ( VarIs<JavascriptGeneratorFunction>(funcCallee) ?
7501+
UnsafeVarTo<JavascriptGeneratorFunction>(funcCallee)->GetGeneratorVirtualScriptFunction()->GetFunctionBody()->HasReferenceableBuiltInArguments()
75027502
: funcCallee->GetFunctionBody()->HasReferenceableBuiltInArguments());
75037503

75047504
if (skipLetAttrForArguments)

test/es7/async-generator-functionality.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//-------------------------------------------------------------------------------------------------------
22
// Copyright (C) Microsoft. All rights reserved.
3+
// Copyright (c) 2021 ChakraCore Project Contributors. All rights reserved.
34
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
45
//-------------------------------------------------------------------------------------------------------
56

@@ -247,6 +248,15 @@ const tests = [
247248
ErrorPromise(this.name, ag.return.call(input), TypeError, `AsyncGenerator.prototype.return should reject with TypeError when called on ${typeof input} ${input}`);
248249
}
249250
}
251+
},
252+
{
253+
name : "AsyncGenerator with complex params containing eval",
254+
body() {
255+
async function* agf(param = 0) {
256+
eval('');
257+
}
258+
AddPromise(this.name, "Evaluate complex params and perform eval - but nothing to do should close", agf().next(), {done : true});
259+
}
250260
}
251261
];
252262

0 commit comments

Comments
 (0)