Repository navigation
Conversation
js_function_toString read "name" through the receiver with JS_GetProperty. For a revoked callable proxy that throws "TypeError: revoked proxy", and for a live proxy it calls the get trap. Per ECMA-262 a proxy that wraps a function keeps [[Call]] after revoke, so IsCallable is true and toString must return a NativeFunction string without touching the handler. Use an empty name for proxies, which matches V8, SpiderMonkey and JavaScriptCore. Fixes: quickjs-ng#1737
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1737
js_function_toStringbuilds the native-code string fromJS_GetProperty(this, "name"). Whenthisis a callable proxy, that read goes through the proxy:A proxy that wraps a function keeps
[[Call]]after it is revoked, soIsCallableis still true andFunction.prototype.toStringmust return a NativeFunction string. The spec does not readnamethere, so the get trap should not run either.The change uses an empty name for proxies (
function () {\n [native code]\n}). V8, SpiderMonkey and JavaScriptCore also print a nameless native function for proxies. Non-proxy functions are unchanged.Tests: added cases to
test_function()intests/test_builtin.js(revoked proxy, get trap not called, non-callable proxy still throwsTypeError). They fail before the change.make testgives the same result as on master (onlytest_std.jstest_poll_handler_orderfails on my macOS machine, with or without this change). A local test262 run ofbuilt-ins/Function/prototype/toString(0/160 errors) andbuilt-ins/Proxy(0/606 errors) passes.