Object spread syntax in console not working
Categories
(DevTools :: Console, defect)
Tracking
(Not tracked)
People
(Reporter: quentin.danjou, Unassigned)
Details
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Firefox/78.0
Steps to reproduce:
- open console
- enter
a = {"b": {foo: 42}}
- enter
{...a["b"], bar: 71}
(Firefox Developper Edition, 78.0b3)
Actual results:
Uncaught SyntaxError: expected expression, got '...'
Expected results:
It should have worked as in Chrome and output:
{foo: 42, bar: 71}
Reporter | ||
Updated•4 years ago
|
Comment 1•4 years ago
|
||
Bugbug thinks this bug should belong to this component, but please revert this change in case of error.
Comment 2•4 years ago
|
||
Hello Quentin!
I think we're hitting Bug 972530
If you change your example to:
a = {"b": {foo: 42}};
({...a["b"], bar: 71})
it's because what you're actually doing is creating a code block.
You can see that the code you are evaluating is actually not valid javascript by navigating to data:text/html,<meta charset=utf8><script>a = {"b": {foo: 42}};{...a}</script>
(you'll see an error in the console, either in Chrome or Firefox).
Chrome is doing some magic to parse evaluated JSON-like object in the console, so that's why you don't see the error there.
We might do it as well at some point (thus making it a bit more obvious)
I'm going to duplicate this bug in favor of Bug 972530, but let me know if you think it's a different issue.
Thanks!
Description
•