Skip to content

Commit eca7a94

Browse files
iamstolishachim-hassani
authored andcommitted
Mark the module function as async when it uses for-await-of.
(cherry picked from commit 27e8ced)
1 parent 293dfbd commit eca7a94

File tree

1 file changed

+7
-0
lines changed
  • graal-js/src/com.oracle.js.parser/src/com/oracle/js/parser

1 file changed

+7
-0
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2957,6 +2957,13 @@ private void forStatement(boolean yield, boolean await) {
29572957
if (!await) {
29582958
throw error(AbstractParser.message(MSG_INVALID_FOR_AWAIT_OF), token);
29592959
}
2960+
if (isModule) {
2961+
ParserContextFunctionNode currentFunction = lc.getCurrentFunction();
2962+
if (currentFunction.isModule()) {
2963+
// Top-level for-await: mark the module function as async.
2964+
currentFunction.setFlag(FunctionNode.IS_ASYNC);
2965+
}
2966+
}
29602967
isForAwaitOf = true;
29612968
next();
29622969
}

0 commit comments

Comments
 (0)