Skip to content

Commit 63093df

Browse files
Merge branch 'master' into feat-optional-chaining
2 parents 2498b2d + 2af598f commit 63093df

File tree

9 files changed

+47
-25
lines changed

9 files changed

+47
-25
lines changed

ContributionAgreement.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,4 @@ This agreement has been signed by:
4444
|Aidan Bickford| BickfordA|
4545
|Ryoichi Kaida| camcam-lemon|
4646
|Lukas Kurz| ShortDevelopment|
47+
|Paul Pluzhnikov|EmployedRussian|

lib/Common/DataStructures/ImmutableList.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//-------------------------------------------------------------------------------------------------------
22
// Copyright (C) Microsoft. All rights reserved.
3+
// Copyright (c) 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
#pragma once
@@ -748,10 +749,16 @@ namespace regex
748749
return result;
749750
}
750751

752+
#ifndef _MSC_VER
753+
bool __attribute__((noinline)) CheckEq(void* obj1, void *obj2) { return obj1 == obj2; }
754+
#else
755+
#define CheckEq(a, b) (a) == (b)
756+
#endif
757+
751758
// Info: Return true if the list is empty.
752759
bool IsEmpty()
753760
{
754-
return this==Empty();
761+
return CheckEq(this, Empty());
755762
}
756763

757764
// Info: Return a list containing the given single value

lib/Common/arm64.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#error Include arm64.h in builds of ARM64 targets only.
1212
#endif
1313

14-
#ifdef __getReg
14+
#if defined(__getReg) || defined(_WIN64)
1515
#define arm64_GET_CURRENT_FRAME() ((LPVOID)__getReg(29))
1616
#else
1717
extern "C" LPVOID arm64_GET_CURRENT_FRAME(void);

lib/Parser/Parse.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3920,7 +3920,7 @@ ParseNodePtr Parser::ParsePostfixOperators(
39203920
{
39213921
AutoMarkInParsingArgs autoMarkInParsingArgs(this);
39223922

3923-
bool isNullPropagating = tkOptChain == this->GetScanner()->m_tkPrevious;
3923+
bool isNullPropagating = tkOptChain == this->GetScanner()->GetPrevious();
39243924
if (fInNew)
39253925
{
39263926
if (isNullPropagating)
@@ -4068,7 +4068,7 @@ ParseNodePtr Parser::ParsePostfixOperators(
40684068
}
40694069
case tkLBrack:
40704070
{
4071-
bool isNullPropagating = tkOptChain == this->GetScanner()->m_tkPrevious;
4071+
bool isNullPropagating = tkOptChain == this->GetScanner()->GetPrevious();
40724072

40734073
this->GetScanner()->Scan();
40744074
IdentToken tok;
@@ -5545,7 +5545,7 @@ ParseNodeFnc * Parser::ParseFncDeclInternal(ushort flags, LPCOLESTR pNameHint, c
55455545
{
55465546
// Class member methods have optional separators. We need to check whether we are
55475547
// getting the IchLim of the correct token.
5548-
Assert(this->GetScanner()->m_tkPrevious == tkRCurly && needScanRCurly);
5548+
Assert(this->GetScanner()->GetPrevious() == tkRCurly && needScanRCurly);
55495549

55505550
this->m_funcInArray += this->GetScanner()->IchMinTok() - /*tkRCurly*/ 1 - ichMin;
55515551
}
@@ -6591,7 +6591,7 @@ bool Parser::FastScanFormalsAndBody()
65916591
{
65926592
int opl;
65936593
OpCode nop;
6594-
tokens tkPrev = this->GetScanner()->m_tkPrevious;
6594+
tokens tkPrev = this->GetScanner()->GetPrevious();
65956595
if ((this->GetHashTbl()->TokIsBinop(tkPrev, &opl, &nop) && nop != knopNone) ||
65966596
(this->GetHashTbl()->TokIsUnop(tkPrev, &opl, &nop) &&
65976597
nop != knopNone &&
@@ -11329,6 +11329,12 @@ ParseNodePtr Parser::ParseStatement()
1132911329
default:
1133011330
if (!this->GetScanner()->FHadNewLine())
1133111331
{
11332+
Token previous = this->GetScanner()->GetPreviousToken();
11333+
if (tkID == previous.tk && wellKnownPropertyPids.await == previous.GetIdentifier(this->GetHashTbl()))
11334+
{
11335+
Error(ERRBadAwait);
11336+
}
11337+
1133211338
Error(ERRnoSemic);
1133311339
}
1133411340
else

lib/Parser/Scan.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1593,7 +1593,7 @@ tokens Scanner<EncodingPolicy>::ScanCore(bool identifyKwds)
15931593
bool seenDelimitedCommentEnd = false;
15941594

15951595
// store the last token
1596-
m_tkPrevious = m_ptoken->tk;
1596+
m_tokenPrevious = *m_ptoken;
15971597
m_iecpLimTokPrevious = IecpLimTok(); // Introduced for use by lambda parsing to find correct span of expression lambdas
15981598
m_ichLimTokPrevious = IchLimTok();
15991599
size_t savedMultiUnits = this->m_cMultiUnits;

lib/Parser/Scan.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//-------------------------------------------------------------------------------------------------------
22
// Copyright (C) Microsoft. All rights reserved.
3+
// Copyright (c) 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
#pragma once
@@ -705,7 +706,8 @@ class Scanner : public IScanner, public EncodingPolicy
705706
}
706707
};
707708

708-
tokens GetPrevious() { return m_tkPrevious; }
709+
tokens GetPrevious() { return m_tokenPrevious.tk; }
710+
Token GetPreviousToken() { return m_tokenPrevious; }
709711
void Capture(_Out_ RestorePoint* restorePoint);
710712
void SeekTo(const RestorePoint& restorePoint);
711713
void SeekToForcingPid(const RestorePoint& restorePoint);
@@ -756,7 +758,7 @@ class Scanner : public IScanner, public EncodingPolicy
756758
Js::ScriptContext* m_scriptContext;
757759
const Js::CharClassifier *charClassifier;
758760

759-
tokens m_tkPrevious;
761+
Token m_tokenPrevious;
760762
size_t m_iecpLimTokPrevious;
761763
charcount_t m_ichLimTokPrevious;
762764

pal/inc/cclock.hpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,9 @@
99
#ifndef CC_PAL_INC_CCLOCK_H
1010
#define CC_PAL_INC_CCLOCK_H
1111

12-
#if defined(_M_ARM64)
13-
#define CCLOCK_ALIGN __declspec(align(8))
14-
#else
15-
#define CCLOCK_ALIGN
16-
#endif
17-
18-
class CCLOCK_ALIGN CCLock
12+
class CCLock
1913
{
14+
__declspec(align(sizeof(size_t)))
2015
char mutexPtr[64]; // keep mutex implementation opaque to consumer (PAL vs non-PAL)
2116

2217
public:

test/es7/asyncawait-syntax.js

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//-------------------------------------------------------------------------------------------------------
22
// Copyright (C) Microsoft. All rights reserved.
3+
// Copyright (c) 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

@@ -58,26 +59,26 @@ var tests = [
5859
{
5960
name: "Await in eval global scope",
6061
body: function () {
61-
assert.throws(function () { eval("var result = await call();"); }, SyntaxError, "'await' keyword is not allowed in eval global scope", "Expected ';'");
62-
assert.throws(function () { eval("await call();"); }, SyntaxError, "'await' keyword is not allowed in eval global scope", "Expected ';'");
62+
assert.throws(function () { eval("var result = await call();"); }, SyntaxError, "'await' keyword is not allowed in eval global scope", `'await' expression not allowed in this context`);
63+
assert.throws(function () { eval("await call();"); }, SyntaxError, "'await' keyword is not allowed in eval global scope", `'await' expression not allowed in this context`);
6364

64-
assert.throws(function () { eval("await a;"); }, SyntaxError, "'await' keyword is not allowed in eval global scope", "Expected ';'");
65-
assert.throws(function () { eval("await a[0];"); }, SyntaxError, "'await' keyword is not allowed in eval global scope", "Expected ';'");
66-
assert.throws(function () { eval("await o.p;"); }, SyntaxError, "'await' keyword is not allowed in eval global scope", "Expected ';'");
65+
assert.throws(function () { eval("await a;"); }, SyntaxError, "'await' keyword is not allowed in eval global scope", `'await' expression not allowed in this context`);
66+
assert.throws(function () { eval("await a[0];"); }, SyntaxError, "'await' keyword is not allowed in eval global scope", `'await' expression not allowed in this context`);
67+
assert.throws(function () { eval("await o.p;"); }, SyntaxError, "'await' keyword is not allowed in eval global scope", `'await' expression not allowed in this context`);
6768
assert.throws(function () { eval("a[await p];"); }, SyntaxError, "'await' keyword is not allowed in eval global scope", "Expected ']'");
68-
assert.throws(function () { eval("a + await p;"); }, SyntaxError, "'await' keyword is not allowed in eval global scope", "Expected ';'");
69-
assert.throws(function () { eval("await p + await q;"); }, SyntaxError, "'await' keyword is not allowed in eval global scope", "Expected ';'");
69+
assert.throws(function () { eval("a + await p;"); }, SyntaxError, "'await' keyword is not allowed in eval global scope", `'await' expression not allowed in this context`);
70+
assert.throws(function () { eval("await p + await q;"); }, SyntaxError, "'await' keyword is not allowed in eval global scope", `'await' expression not allowed in this context`);
7071
assert.throws(function () { eval("foo(await p, await q);"); }, SyntaxError, "'await' keyword is not allowed in eval global scope", "Expected ')'");
7172

7273
assert.throws(function () { eval("var lambdaParenNoArg = await () => x < y;"); }, SyntaxError, "'await' keyword is not allowed with a non-async lambda expression", "Syntax error");
73-
assert.throws(function () { eval("var lambdaArgs = await async (a, b ,c) => a + b + c;"); }, SyntaxError, "There miss parenthises", "Expected ';'");
74+
assert.throws(function () { eval("var lambdaArgs = await async (a, b ,c) => a + b + c;"); }, SyntaxError, "There miss parenthises", `'await' expression not allowed in this context`);
7475
assert.throws(function () { eval("var lambdaArgs = await (async (a, b ,c) => a + b + c);"); }, ReferenceError, "The 'await' function doesn't exists in this scope", "'await' is not defined");
7576
}
7677
},
7778
{
7879
name: "Await in a non-async function",
7980
body: function () {
80-
assert.throws(function () { eval("function method() { var x = await call(); }"); }, SyntaxError, "'await' cannot be used in a non-async function.", "Expected ';'");
81+
assert.throws(function () { eval("function method() { var x = await call(); }"); }, SyntaxError, "'await' cannot be used in a non-async function.", `'await' expression not allowed in this context`);
8182
}
8283
},
8384
{
@@ -216,6 +217,14 @@ var tests = [
216217
assert.throws(function () { eval("async function af() { (b = (c = await => {}) => {}) => {}; }"); }, SyntaxError, "await cannot appear as the formal name of an unparathensized arrow function in a nested case too", "Unexpected token '=>' after 'await'");
217218
}
218219
},
220+
{
221+
name: "Specific error message when using 'await' as a keyword outside 'async' context",
222+
body: function () {
223+
assert.throws(function () {
224+
eval(`await new Promise(() => {});`);
225+
}, SyntaxError, "await is not a keyword here", `'await' expression not allowed in this context`);
226+
}
227+
}
219228
];
220229

221230
testRunner.runTests(tests, { verbose: WScript.Arguments[0] != "summary" });

tools/regenByteCode.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@ def append_bytecode(header, command, in_path, file_name, error):
137137
job.wait()
138138
if job.returncode != 0:
139139
print(error)
140+
print('Command line: ')
141+
print(*command_with_file)
140142
sys.exit(1)
141143

142144
# Load file and ensure line endings are '\n' if on windows

0 commit comments

Comments
 (0)