-
Notifications
You must be signed in to change notification settings - Fork 866
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
Object.assign() should copy undefined properties, I think #780
Comments
https://www.ecma-international.org/ecma-262/11.0/index.html#sec-object.assign Section 19.1.2.1, step 4.a.iii.2 seems to indicate the check is appropriate. |
Thanks for replying, Tony! I'm not sure that's a correct reading of that spec ... From earlier in the doc, "[[GetOwnProperty]]" is described as:
So when reading this section:
I believe that it is correct to say that SpiderMonkey and V8 both copy properties with undefined values, too (not that that's necessarily definitive). Thoughts? |
Thanks for the analysis of the spec. You may indeed be right. I'm sure that there are tests in the "test262" directory for this. Some of them may be disabled (in test262.properties) which is usually a sign that we missed something. Perhaps if you try looking to see what's enabled and enabling anything that might be disabled regarding Object.assign, we might be able to quickly zero on on the correct behavior. |
@dcitron I'm not experienced with reading these specs nor am I an expert on javascript internals. I do think your interpretation is correct. I am still a bit confused about how |
Perhaps there aren't tests in the latest "test262". |
My reading of the spec is that the Regardless, the spec is pretty clear that there should NOT be a check on the value of the property, so assign should copy over properties with an undefined value |
Sorry but i have to reopen this issue. tuchida's fix seems to introduce a new problem. Have applied this change to HtmlUnit and one library tests failed. Maybe @tuchida can have a look (please). |
@tuchida are you looking into this? |
Yes, I look it lightly. However, I could not proceed because I was not sure which specification |
Apologies for the delay! I haven't forgotten! I'll try to get to it this coming week. |
Hi @tuchida and @rbri ! I have a fix that passes all Here's what I found: the current code is not perfectly following the flow specified by https://262.ecma-international.org/12.0/#sec-ordinarysetwithowndescriptor What's happening right now (if I'm correct!) is:
My fix involves doing the right thing at step 3.d.iv and 3.d.ii in the picture above, which means:
I hope any of that makes any kind of sense! In short, my change is to add this code here: I also made a small change to Slot.java to factor out Question!!! How should I proceed? I think I cannot push changes directly to rbri:assign_with_prototoype, right? Should I just make my own fork and my own branch and push my changes plus @rbri's test case and make a whole new PR? What's the correct procedure here? |
Have no pointers on what the best way to proceed is, just wanted to say: great analyses! Note that this fix might also fix some test262 tests that are currently not passing. You could check that by running the test262 TestSuite and see if any such tests are reported. If yes, you can regenerate test262.properties and include the up[dated version in the eventual PR. See https://github.com/mozilla/rhino/tree/master/testsrc for the docs about doing so |
Many thanks!
I think this will be the right way. |
Great! I'll do that and I'll see about the test262 suite as well. |
Hi, @p-bakker -- I tried to do that, but it didn't report anything. Did I miss a step or does this mean that my fix didn't fix any of the test262 tests?
|
… the case where the target object inherits from a prototype that already contains the property being set
Do I need to do anything else or is it sufficient that the PR is currently open? |
Sorry but we are all overloaded with work - will have a look at the weekend |
No rush at all! It took me forever and a day to even fix it! I just wanted to make sure I wasn't still blocking anything :) |
Juste made another PR for this (#1294) will try both suggested solutions using the HtmlUnit test suite and report the results here. |
PR #1294 fixes this (hopefully) finally |
Hi! It looks like
Object.assign()
should copy undefined properties:However, the Rhino code is skipping undefined values:
Is there a reason for those
!Undefined.isUndefined(val)
checks?Thanks!
The text was updated successfully, but these errors were encountered: