Skip to content
This repository was archived by the owner on Oct 15, 2020. It is now read-only.

Commit ef8cd26

Browse files
boingoingchakrabot
authored andcommitted
deps: update ChakraCore to chakra-core/ChakraCore@45a175d1c7
[1.8>1.9] [MERGE #4612 @boingoing] OS#13976524: Force scanner to create pid for string constant trailing defer-parsed compact-body lambda Merge pull request #4612 from boingoing:13976524 Lambda with compact-body which is defer-parsed and which is trailed immediately by a string constant can cause the string constant to miss having a pid created. When we try to load the string constant table in `ByteCodeGenerator`, we'll hit an AV with this pid being nullptr. Fix by forcing the scanner to create a pid for this string constant - only for the single case of a string constant token immediately following the single-expression lambda body which is defer-parsed. Test case looks like this: ``` jtmchw => z '123' ``` Fixes: https://microsoft.visualstudio.com/web/wi.aspx?id=13976524 Reviewed-By: chakrabot <chakrabot@users.noreply.github.com>
1 parent e3d6b28 commit ef8cd26

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

deps/chakrashim/core/lib/Parser/Parse.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7101,7 +7101,13 @@ void Parser::ParseExpressionLambdaBody(ParseNodePtr pnodeLambda)
71017101

71027102
IdentToken token;
71037103
charcount_t lastRParen = 0;
7104+
7105+
// We need to disable deferred parse mode in the scanner because the lambda body doesn't end with a right paren.
7106+
// The scanner needs to create a pid in the case of a string constant token immediately following the lambda body expression.
7107+
// Otherwise, we'll save null for the string constant pid which will AV during ByteCode generation.
7108+
BYTE fScanDeferredFlagsSave = m_pscan->SetDeferredParse(FALSE);
71047109
ParseNodePtr result = ParseExpr<buildAST>(koplAsg, nullptr, TRUE, FALSE, nullptr, nullptr, nullptr, &token, false, nullptr, &lastRParen);
7110+
m_pscan->SetDeferredParseFlags(fScanDeferredFlagsSave);
71057111

71067112
this->MarkEscapingRef(result, &token);
71077113

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//-------------------------------------------------------------------------------------------------------
2+
// Copyright (C) Microsoft. All rights reserved.
3+
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
4+
//-------------------------------------------------------------------------------------------------------
5+
6+
WScript.LoadScriptFile("..\\UnitTestFramework\\UnitTestFramework.js");
7+
8+
var tests = [
9+
{
10+
name: "Lambda with a string constant on the following line shouldn't AV",
11+
body: function () {
12+
jtmchw => z
13+
'123'
14+
}
15+
},
16+
];
17+
18+
testRunner.runTests(tests, { verbose: WScript.Arguments[0] != "summary" });

deps/chakrashim/core/test/es6/rlexe.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1414,6 +1414,13 @@
14141414
<compile-flags>-force:deferparse -args summary -endargs</compile-flags>
14151415
</default>
14161416
</test>
1417+
<test>
1418+
<default>
1419+
<files>bug_OS13976524.js</files>
1420+
<tags>BugFix</tags>
1421+
<compile-flags>-force:deferparse -args summary -endargs</compile-flags>
1422+
</default>
1423+
</test>
14171424
<test>
14181425
<default>
14191426
<files>DeferParseLambda.js</files>

0 commit comments

Comments
 (0)