diff --git a/source/runtime.c b/source/runtime.c index f99557e8..b5c41bf1 100644 --- a/source/runtime.c +++ b/source/runtime.c @@ -3955,8 +3955,10 @@ JSValue JS_ToNumber (JSContext *ctx, JSValue val) { ret = val; break; case JS_TAG_BOOL: + ret = JS_NewInt32 (ctx, JS_ToBool (ctx, val)); + break; case JS_TAG_NULL: - ret = JS_NewInt32 (ctx, JS_VALUE_GET_INT (val)); + ret = JS_NewInt32 (ctx, 0); break; case JS_TAG_STRING_IMM: return JS_ThrowTypeError (ctx, "cannot convert text to a number");