You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/* return -1 if exception (proxy case) or true/false */intJS_IsArray(JSContext*ctx, JSValueval)
That's jarringly different from JS_IsObject/JS_IsPromise/etc. and returning a ternary instead of a boolean like the other functions is a bug magnet.
The reason it takes a JSContext pointer as its first argument is because it transparently handles proxies and guards against stack overflow in case the proxy's target object loops back on itself.
I don't think it should try to handle proxies because that's inconsistent. Neither JS_IsObject or JS_IsPromise do that, for example.
My proposal:
definitely remove proxy handling from JS_IsArray
optionally add a JS_IsProxy function and maybe JS_GetProxyTarget + JS_GetProxyHandler?
The text was updated successfully, but these errors were encountered:
bnoordhuis
added a commit
to bnoordhuis/quickjs
that referenced
this issue
Mar 1, 2025
This commit also turns JS_IsArray into a simple predicate function.
It no longer punches automatically through proxies because that can
raise exceptions and is inconsistent with the other predicate functions.
Fixes: quickjs-ng#938
JS_IsArray currently has this prototype:
That's jarringly different from JS_IsObject/JS_IsPromise/etc. and returning a ternary instead of a boolean like the other functions is a bug magnet.
The reason it takes a JSContext pointer as its first argument is because it transparently handles proxies and guards against stack overflow in case the proxy's target object loops back on itself.
I don't think it should try to handle proxies because that's inconsistent. Neither JS_IsObject or JS_IsPromise do that, for example.
My proposal:
definitely remove proxy handling from JS_IsArray
optionally add a JS_IsProxy function and maybe JS_GetProxyTarget + JS_GetProxyHandler?
The text was updated successfully, but these errors were encountered: