Skip to content

Commit 614020a

Browse files
authored
Add JS_PROMISE_NOT_A_PROMISE to JSPromiseStateEnum (#1269)
Fixes: #1268
1 parent d96c04a commit 614020a

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

quickjs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50558,7 +50558,7 @@ JSPromiseStateEnum JS_PromiseState(JSContext *ctx, JSValueConst promise)
5055850558
{
5055950559
JSPromiseData *s = JS_GetOpaque(promise, JS_CLASS_PROMISE);
5056050560
if (!s)
50561-
return -1;
50561+
return JS_PROMISE_NOT_A_PROMISE;
5056250562
return s->promise_state;
5056350563
}
5056450564

quickjs.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1013,7 +1013,9 @@ typedef struct {
10131013
JS_EXTERN void JS_SetSharedArrayBufferFunctions(JSRuntime *rt, const JSSharedArrayBufferFunctions *sf);
10141014

10151015
typedef enum JSPromiseStateEnum {
1016-
JS_PROMISE_PENDING,
1016+
// argument to JS_PromiseState() was not in fact a promise
1017+
JS_PROMISE_NOT_A_PROMISE = -1,
1018+
JS_PROMISE_PENDING = 0,
10171019
JS_PROMISE_FULFILLED,
10181020
JS_PROMISE_REJECTED,
10191021
} JSPromiseStateEnum;

0 commit comments

Comments
 (0)