Skip to content

Commit ec98665

Browse files
committed
[GR-37478] Avoiding AssertionErrors during parsing of async arrow functions.
PullRequest: js/2377
2 parents 3c7d0b5 + 1dccd53 commit ec98665

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

graal-js/src/com.oracle.js.parser/src/com/oracle/js/parser/Parser.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6231,6 +6231,9 @@ private Expression assignmentExpression(boolean in, boolean yield, boolean await
62316231
if (asyncArrow && exprLhs instanceof IdentNode && isBindingIdentifier() && lookaheadIsArrow()) {
62326232
// async ident =>
62336233
exprLhs = primaryExpression(yield, await);
6234+
if (exprLhs instanceof IdentNode && AWAIT.getName().equals(((IdentNode) exprLhs).getName())) {
6235+
throw error(AbstractParser.message(MSG_INVALID_ARROW_PARAMETER), exprLhs.getToken());
6236+
}
62346237
}
62356238

62366239
if (ES6_ARROW_FUNCTION && type == ARROW && isES6()) {
@@ -6292,7 +6295,6 @@ private Expression arrowFunction(final long startToken, final int functionLine,
62926295
coverArrowFunction = null;
62936296
}
62946297
assert functionNode.isArrow() && !functionNode.isCoverArrowHead();
6295-
assert functionNode.isAsync() == async;
62966298
functionNode.setInternalName(ARROW_FUNCTION_NAME);
62976299
functionNode.setFlag(FunctionNode.IS_ANONYMOUS);
62986300

@@ -6303,6 +6305,7 @@ private Expression arrowFunction(final long startToken, final int functionLine,
63036305
Block functionBody;
63046306
try {
63056307
convertArrowFunctionParameterList(paramListExpr, functionNode);
6308+
assert functionNode.isAsync() == async;
63066309
functionBody = functionBody(functionNode);
63076310
} finally {
63086311
restoreBlock(parameterBlock);
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/*
2+
* Copyright (c) 2022, 2022, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
6+
*/
7+
8+
load('assert.js');
9+
10+
assertThrows(function() {
11+
eval('+async()=>{}');
12+
}, SyntaxError);
13+
14+
assertThrows(function() {
15+
eval('async function f() { await async()=>{}; }');
16+
}, SyntaxError);

graal-nodejs/test/parallel/parallel.status

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ test-v8-getheapsnapshot-twice: SKIP
6969
# https://example.com does not work in CI
7070
test-https-agent-unref-socket: SKIP
7171

72+
# uses an expired certificate, see https://github.com/nodejs/node/pull/42342
73+
test-https-selfsigned-no-keycertsign-no-crash: FAIL
74+
7275
# Worker resource limits are not supported
7376
test-worker-resource-limits: FAIL
7477
test-worker-nearheaplimit-deadlock: SKIP

0 commit comments

Comments
 (0)