mirror of
https://github.com/DoneJS-Runtime/quickjs-done-nextgen.git
synced 2025-01-09 17:43:15 +00:00
Fix async iterator missing throw method behavior (#485)
This commit is contained in:
parent
408fed8fa5
commit
cee3b88edb
2 changed files with 30 additions and 24 deletions
46
quickjs.c
46
quickjs.c
|
@ -6609,36 +6609,45 @@ JSValue JS_NewError(JSContext *ctx)
|
|||
return JS_NewObjectClass(ctx, JS_CLASS_ERROR);
|
||||
}
|
||||
|
||||
/* fmt and arguments may be pure ASCII or UTF-8 encoded contents */
|
||||
static JSValue JS_ThrowError2(JSContext *ctx, JSErrorEnum error_num,
|
||||
const char *fmt, va_list ap, BOOL add_backtrace)
|
||||
static JSValue JS_MakeError(JSContext *ctx, JSErrorEnum error_num,
|
||||
const char *message, BOOL add_backtrace)
|
||||
{
|
||||
char buf[256];
|
||||
JSValue obj, ret, msg;
|
||||
JSValue obj, msg;
|
||||
|
||||
vsnprintf(buf, sizeof(buf), fmt, ap);
|
||||
if (error_num == JS_PLAIN_ERROR)
|
||||
if (error_num == JS_PLAIN_ERROR) {
|
||||
obj = JS_NewError(ctx);
|
||||
else
|
||||
} else {
|
||||
obj = JS_NewObjectProtoClass(ctx, ctx->native_error_proto[error_num],
|
||||
JS_CLASS_ERROR);
|
||||
if (unlikely(JS_IsException(obj))) {
|
||||
/* out of memory: throw JS_NULL to avoid recursing */
|
||||
obj = JS_NULL;
|
||||
} else {
|
||||
msg = JS_NewString(ctx, buf);
|
||||
}
|
||||
if (JS_IsException(obj))
|
||||
return JS_EXCEPTION;
|
||||
msg = JS_NewString(ctx, message);
|
||||
if (JS_IsException(msg))
|
||||
msg = JS_NewString(ctx, "Invalid error message");
|
||||
if (!JS_IsException(msg)) {
|
||||
JS_DefinePropertyValue(ctx, obj, JS_ATOM_message, msg,
|
||||
JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE);
|
||||
}
|
||||
}
|
||||
if (add_backtrace) {
|
||||
if (add_backtrace)
|
||||
build_backtrace(ctx, obj, NULL, 0, 0, 0);
|
||||
return obj;
|
||||
}
|
||||
ret = JS_Throw(ctx, obj);
|
||||
return ret;
|
||||
|
||||
/* fmt and arguments may be pure ASCII or UTF-8 encoded contents */
|
||||
static JSValue JS_ThrowError2(JSContext *ctx, JSErrorEnum error_num,
|
||||
const char *fmt, va_list ap, BOOL add_backtrace)
|
||||
{
|
||||
char buf[256];
|
||||
JSValue obj;
|
||||
|
||||
vsnprintf(buf, sizeof(buf), fmt, ap);
|
||||
obj = JS_MakeError(ctx, error_num, buf, add_backtrace);
|
||||
if (unlikely(JS_IsException(obj))) {
|
||||
/* out of memory: throw JS_NULL to avoid recursing */
|
||||
obj = JS_NULL;
|
||||
}
|
||||
return JS_Throw(ctx, obj);
|
||||
}
|
||||
|
||||
static JSValue JS_ThrowError(JSContext *ctx, JSErrorEnum error_num,
|
||||
|
@ -47393,7 +47402,8 @@ static JSValue js_async_from_sync_iterator_next(JSContext *ctx, JSValue this_val
|
|||
err = js_create_iterator_result(ctx, js_dup(argv[0]), TRUE);
|
||||
is_reject = 0;
|
||||
} else {
|
||||
err = js_dup(argv[0]);
|
||||
err = JS_MakeError(ctx, JS_TYPE_ERROR, "throw is not a method",
|
||||
TRUE);
|
||||
is_reject = 1;
|
||||
}
|
||||
goto done_resolve;
|
||||
|
|
|
@ -8,8 +8,6 @@ test262/test/built-ins/AsyncFromSyncIteratorPrototype/next/yield-next-rejected-p
|
|||
test262/test/built-ins/AsyncFromSyncIteratorPrototype/next/yield-next-rejected-promise-close.js:64: strict mode: TypeError: $DONE() not called
|
||||
test262/test/built-ins/AsyncFromSyncIteratorPrototype/throw/iterator-result-rejected-promise-close.js:74: TypeError: $DONE() not called
|
||||
test262/test/built-ins/AsyncFromSyncIteratorPrototype/throw/iterator-result-rejected-promise-close.js:74: strict mode: TypeError: $DONE() not called
|
||||
test262/test/built-ins/AsyncFromSyncIteratorPrototype/throw/throw-null.js:52: TypeError: $DONE() not called
|
||||
test262/test/built-ins/AsyncFromSyncIteratorPrototype/throw/throw-null.js:52: strict mode: TypeError: $DONE() not called
|
||||
test262/test/built-ins/AsyncFromSyncIteratorPrototype/throw/throw-result-poisoned-wrapper.js:81: TypeError: $DONE() not called
|
||||
test262/test/built-ins/AsyncFromSyncIteratorPrototype/throw/throw-result-poisoned-wrapper.js:81: strict mode: TypeError: $DONE() not called
|
||||
test262/test/built-ins/AsyncFromSyncIteratorPrototype/throw/throw-undefined-get-return-undefined.js:64: TypeError: $DONE() not called
|
||||
|
@ -20,8 +18,6 @@ test262/test/built-ins/AsyncFromSyncIteratorPrototype/throw/throw-undefined-retu
|
|||
test262/test/built-ins/AsyncFromSyncIteratorPrototype/throw/throw-undefined-return-not-object.js:72: strict mode: TypeError: $DONE() not called
|
||||
test262/test/built-ins/AsyncFromSyncIteratorPrototype/throw/throw-undefined-return-object.js:66: TypeError: $DONE() not called
|
||||
test262/test/built-ins/AsyncFromSyncIteratorPrototype/throw/throw-undefined-return-object.js:66: strict mode: TypeError: $DONE() not called
|
||||
test262/test/built-ins/AsyncFromSyncIteratorPrototype/throw/throw-undefined.js:41: TypeError: $DONE() not called
|
||||
test262/test/built-ins/AsyncFromSyncIteratorPrototype/throw/throw-undefined.js:41: strict mode: TypeError: $DONE() not called
|
||||
test262/test/built-ins/RegExp/lookahead-quantifier-match-groups.js:27: Test262Error: Expected [a, abc] and [a, undefined] to have the same contents. ? quantifier
|
||||
test262/test/built-ins/RegExp/lookahead-quantifier-match-groups.js:27: strict mode: Test262Error: Expected [a, abc] and [a, undefined] to have the same contents. ? quantifier
|
||||
test262/test/built-ins/RegExp/nullable-quantifier.js:21: Test262Error: The regex is expected to match the whole string Expected SameValue(«a», «ab») to be true
|
||||
|
|
Loading…
Reference in a new issue