Closed Bug 1615781 Opened 4 years ago Closed 4 years ago

Nullish coalescing operator inside async function fails in web console

Categories

(DevTools :: Console, defect)

73 Branch
defect
Not set
normal

Tracking

(firefox74 verified, firefox75 verified)

VERIFIED FIXED
Firefox 75
Tracking Status
firefox74 --- verified
firefox75 --- verified

People

(Reporter: subs, Assigned: nchevobbe)

References

Details

Attachments

(1 file)

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:73.0) Gecko/20100101 Firefox/73.0

Steps to reproduce:

Similar to bug 1599163, I was trying out the nullish coalescing operator in the console, but inside an async function.

Actual results:

The console failed to make the function, and didn't produce an error. (Returned undefined like normal.)

Here's the smallest test case that fails:

async function testa() { await x; let y = 1 ?? 2; }
(Type 'testa' and enter in console, and it won't be there.)

by contrast these work fine:

async function testb() { let y = 1 ?? 2; }
async function testc() { await x; let y = 1 || 2; }
(Typing 'testb' or 'testc' bring up their respective functions as expected.)

Expected results:

Typing 'testa' and enter should have brought up the function.

Note that the function seems to work fine in a .js file (or loaded in a script tag).

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

Component: Untriaged → Console
Product: Firefox → DevTools

Since both operators are now supported in Firefox,
we should make sure we can use them in top-level
await expression in the console.
Unit tests are added to ensure this works as expected.

Assignee: nobody → nchevobbe
Blocks: 1615999
Pushed by nchevobbe@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/ee79f0156832
Enable nullish coalescing and optional chaining operators when parsing console expression. r=loganfsmyth.
Status: UNCONFIRMED → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 75

Comment on attachment 9127029 [details]
Bug 1615781 - Enable nullish coalescing and optional chaining operators when parsing console expression. r=loganfsmyth.

Beta/Release Uplift Approval Request

  • User impact if declined: User won't be able to declare an async function with the nullish coalesce operator or the optional chaining operator from the console.
    This would be weird as it works in regular JS files.
  • Is this code covered by automated tests?: Yes
  • Has the fix been verified in Nightly?: No
  • Needs manual test from QE?: Yes
  • If yes, steps to reproduce: 1. Open the console
  1. Evaluate the following
async function test(x) { 
  await 1; 
  return x?.value ?? 2; 
}
  1. Make sure you can call the newly created test function.
  • List of other uplifts needed: None
  • Risk to taking this patch: Low
  • Why is the change risky/not risky? (and alternatives if risky): devtools only, covered by tests, babel-configuration only
  • String changes made/needed:
Attachment #9127029 - Flags: approval-mozilla-beta?
Flags: qe-verify+

Comment on attachment 9127029 [details]
Bug 1615781 - Enable nullish coalescing and optional chaining operators when parsing console expression. r=loganfsmyth.

Looks safe, has tests and doesn't impact end_users, uplift approved for our next beta, thanks.

Attachment #9127029 - Flags: approval-mozilla-beta? → approval-mozilla-beta+
QA Whiteboard: [qa-triaged]

Verify as fixed on Firefox Nightly 75.0a1 (2020-02-19) and on Firefox 74.0b5 on Windows 10 x64, Ubuntu 18.04 x64 and on Mac OS X 10.14.

Status: RESOLVED → VERIFIED
QA Whiteboard: [qa-triaged]
Flags: qe-verify+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: