Closed Bug 1644987 Opened 4 years ago Closed 4 years ago

Object spread syntax in console not working

Categories

(DevTools :: Console, defect)

78 Branch
defect

Tracking

(Not tracked)

RESOLVED DUPLICATE of bug 972530

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}

Summary: Object spread syntax in console not work → Object spread syntax in console not working

Bugbug thinks this bug should belong to this component, but please revert this change in case of error.

Component: Untriaged → Console
Product: Firefox → DevTools

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!

Status: UNCONFIRMED → RESOLVED
Closed: 4 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.