Skip to content

Commit

Permalink
Fix global-await issue
Browse files Browse the repository at this point in the history
* Print unhandled reject error for developer in shell
* Fix await expression parsing bug

Signed-off-by: Seonghyun Kim <[email protected]>
  • Loading branch information
ksh8281 authored and clover2123 committed Dec 1, 2023
1 parent 184295c commit 799bc4f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/parser/esprima_cpp/esprima.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3455,6 +3455,10 @@ class Parser {
}
}

if (UNLIKELY(exprNode->type() == ASTNodeType::AwaitExpression)) {
this->throwError(Messages::InvalidLHSInAssignment);
}

if (!this->match(Substitution)) {
this->context->isAssignmentTarget = false;
this->context->isBindingElement = false;
Expand Down
5 changes: 5 additions & 0 deletions src/shell/Shell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1097,6 +1097,11 @@ int main(int argc, char* argv[])
Memory::setGCFrequency(24);

PersistentRefHolder<VMInstanceRef> instance = VMInstanceRef::create();
instance->registerPromiseRejectCallback([](ExecutionStateRef* state, PromiseObjectRef* promise, ValueRef* value, VMInstanceRef::PromiseRejectEvent event) {
if (event == VMInstanceRef::PromiseRejectWithNoHandler) {
fprintf(stderr, "Unhandled promise reject %s:\n", value->toStringWithoutException(state->context())->toStdUTF8String().data());
}
});
PersistentRefHolder<ContextRef> context = createEscargotContext(instance.get());

if (getenv("GC_FREE_SPACE_DIVISOR") && strlen(getenv("GC_FREE_SPACE_DIVISOR"))) {
Expand Down
2 changes: 1 addition & 1 deletion test/vendortest

0 comments on commit 799bc4f

Please sign in to comment.