-
Notifications
You must be signed in to change notification settings - Fork 850
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
first implementation of Reflect & Proxy support #1332
Conversation
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.
Very interesting. I will look it properly later.
@@ -126,6 +126,9 @@ public interface Scriptable { | |||
*/ | |||
public boolean has(int index, Scriptable start); | |||
|
|||
/** A version of delete for properties with Symbol keys. */ | |||
public boolean has(Symbol key, Scriptable start); |
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.
Is it safe compatibility-wise to add methods to Scriptable
? If it is not safe, why not add it as Default Methods?
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.
@tuchida you are right, have changed the impl to use the same approach as the other symbol based methods
testsrc/test262.properties
Outdated
@@ -1309,7 +1301,36 @@ built-ins/Promise 405/599 (67.61%) | |||
|
|||
~built-ins/Proxy | |||
|
|||
~built-ins/Reflect | |||
built-ins/Reflect 29/139 (20.86%) |
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.
For the failing Reflect tests (besides the ones failing because they rely on unsupported features like Proxy and computed-property-names or due to being strict mode related): why are these failing?
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.
these are mainly setter tests, from a first look they fail because i found no good way to provide the correct return value (false) if the setter is 'ignored'.
At least i found no way to do it without changing the current impl.
But i think 20% failing are 80% passing and so it's worth to start with this.....
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.
I think it matters why they fail: if those tests fail because of Reflect exhibiting wrong behavior it's a bigger issue that when they fail because something is not supported and errors out.
Because if it exhibits the wrong behavior, people might start to depend on it and thus fixing it becomes sort of a breaking change down the road
|
||
@Test | ||
public void ownKeysDeleteObj() { | ||
String js = "var o = { d: 42 };\n" + "delete o.d;\n" + "'' + Reflect.ownKeys({}).length"; |
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.
Is this correct?
String js = "var o = { d: 42 };\n" + "delete o.d;\n" + "'' + Reflect.ownKeys({}).length"; | |
String js = "var o = { d: 42 };\n" + "delete o.d;\n" + "'' + Reflect.ownKeys(o).length"; |
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.
You are right, fixed
if (args.length < 3) { | ||
throw ScriptRuntime.typeErrorById( | ||
"msg.method.missing.parameter", | ||
"Reflect.apply", |
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.
Perhaps it goes like this.
"Reflect.apply", | |
"Reflect.defineProperty", |
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.
Stupid me, fixed
This looks like a good change to me, although I share the concerns about test262 tests in the built-ins/Reflect suite that are failing. Do you think that there's a way to make more of those tests pass? Otherwise, it depends on the failures because I don't either want to have users depend on an incorrect implementation if we're not passing the tests. |
e1b1c67
to
64b4cf3
Compare
@gbrail, @tuchida, @p-bakker i think the Proxy support is now also worth to look at. I have not updated the test262.properties because there is still some more work to be done
This is now part of HtmlUnit - the implementation makes some huge test suites working. And any help with this is appreciated (as always) |
Nice! Could you elaborate a bit on the implementation? Does it support Scriptables as target? The tests that currently aren't passing, are they related to specific features? Etc. |
@p-bakker Like for the Reflect stuff (have that migrated to Lambda in between also) the most critical point is the delete stuff that has to have a return value but the whole Rhino engine does not. At the moment i have no real idea how to fix that in a backward compatible way. If you like to have a closer look i suggest to
This will give you a good impression of the effects this (monster) pr has. |
I guess this is the answer ;-) But in the implementation i tried to be as generic as possible (i guess more generic as your impl) but of course there is room for improvement. |
current status of the impl
|
…e; the object might be a NativeSymbol or a SymbolKey (found while working on mozilla#1332)
…object might be a NativeSymbol or a SymbolKey (found while working on #1332)
…he other symbol based methods)
milestone I reached
…/Reflect 20/139 (14.39%)]
SymbolKeys are shallowEq to symbols isArray has to take care of proxies
fix missing return for put traps
Closed? |
Not really, looks like i made a mistake somewhere during the last rebase.... |
@gbrail, @tuchida, @p-bakker please have a look....