-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(ecmascript): proxy call method #510
Conversation
Yup, we've not had callable proxies so Do you want to try your hand at implementing it? It would basically just be 90% direct copy of the |
I’d love to do it! I’ll probably start implementing it tomorrow or the day after! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One nit and one issue (in two places though; remember to fix both call()
s to be call_function()
).
But generally looks good to me! Thank you again <3 We're really going places this week; we're now well past 50% passing rate!
ba71fc8
to
c9b5d35
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, good job! <3
hi, @aapoalas The Callable struct would look like the following, right? #[derive(Clone, Copy, PartialEq)]
#[repr(u8)]
pub enum Callable<'a> {
BoundFunction(BoundFunction<'a>) = BOUND_FUNCTION_DISCRIMINANT,
BuiltinFunction(BuiltinFunction<'a>) = BUILTIN_FUNCTION_DISCRIMINANT,
ECMAScriptFunction(ECMAScriptFunction<'a>) = ECMASCRIPT_FUNCTION_DISCRIMINANT,
BuiltinGeneratorFunction = BUILTIN_GENERATOR_FUNCTION_DISCRIMINANT,
BuiltinConstructorFunction(BuiltinConstructorFunction<'a>) =
BUILTIN_CONSTRUCTOR_FUNCTION_DISCRIMINANT,
BuiltinPromiseResolvingFunction(BuiltinPromiseResolvingFunction<'a>) =
BUILTIN_PROMISE_RESOLVING_FUNCTION_DISCRIMINANT,
BuiltinPromiseCollectorFunction = BUILTIN_PROMISE_COLLECTOR_FUNCTION_DISCRIMINANT,
BuiltinProxyRevokerFunction = BUILTIN_PROXY_REVOKER_FUNCTION,
Proxy(Proxy) = PROXY_DISCRIMINANT,
} And in this case, would you also add things like unbind to the Callable enum? Would it essentially be the same implementation as Function? 👀 |
Yup, exactly |
ok, thank you! |
I implemented the call method (also part of apply), but the number of crashes in test262 has increased. For example:
https://github.com/tc39/test262/blob/ff9763729d242b54a9f11bbc614670db3888c8d2/test/built-ins/Proxy/apply/call-result.js
When
p.call(Function.prototype.call)
is invoked, and p.apply is called, it results in the error:Uncaught exception: TypeError: Not a callable value
I believe this is related to the following section of code:
nova/nova_vm/src/ecmascript/abstract_operations/testing_and_comparison.rs
Lines 67 to 89 in 55e48f9
Here, the issue is that it returns None. As the comment suggests, I suspect that if we change
Option<Function>
toOption<Callable>
, thetry_into()
method would return true and resolve the issue.ref: #160
doc: https://tc39.es/ecma262/#sec-proxy-object-internal-methods-and-internal-slots-call-thisargument-argumentslist