Closed Bug 1527867 Opened 7 years ago Closed 7 years ago

BigInt values print as "null" in the console

Categories

(DevTools :: Console, defect, P1)

defect

Tracking

(firefox68 fixed)

RESOLVED FIXED
Firefox 68
Tracking Status
firefox68 --- fixed

People

(Reporter: wingo, Assigned: nchevobbe)

References

Details

Attachments

(1 file)

Steps to reproduce:

(1) Build Firefox from m-c with default options
(2) Launch Firefox
(3) go to about:config, enable javascript.options.bigint
(4) open wikipedia or something, C-S-k for dev console
(5) type in 1n or any expression evaluating to a bigint

Expected result: value prints as 1 (or possibly 1n). Note that ToString(1n) is "1", but probably in the dev console we should print these values in a different way to indicate they are bigints and not normal numbers.

Current result: value prints as null

Thanks for the bug report Andy.

I took a look at that, and in webconsole actor, evalWithDebugger returns { result: { return: null }}.

I dug a bit deeper, and dbgWindow.executeInGlobalWithBindings("1n", {}) in devtools/server/actors/webconsole/eval-with-debugger.js#134 returns { return: null }.

Jim, Logan, would you know what's happening here? It seems like something we want to have at the same time as BigInt support ride the train.


Once we have a clear idea of what's happening here, there will probably some work required to send the correct packet shape to the client, and on the client to render this as the user would expect (I guess the 1n notation).

Flags: needinfo?(lsmyth)
Flags: needinfo?(jimb)
Priority: -- → P1
Blocks: js-bigint-ship
No longer blocks: js-bigint

Just FWIW the reference for ToString on bigint values: https://tc39.github.io/proposal-bigint/#sec-tostring

Also FYI it looks like we are getting close to feature-complete on BigInt. There's one one missing core feature (https://bugzilla.mozilla.org/show_bug.cgi?id=1501105), and also the whole typedarray integration hasn't landed yet either (https://bugzilla.mozilla.org/show_bug.cgi?id=1456569, see spec here https://tc39.github.io/proposal-bigint/#sec-typedarrays-and-dataview). Anyway what I am saying is that it is probably a good time for devtools work -- neither too soon nor too late.

See Also: → 1527912

Scratch what I said in Comment 1, I was seeing null because it's not supported in the console 🤦‍♀️
Evaluating typeof(dbgWindow.executeInGlobal("1n").return) does return "bigint", which means we have everything we need to support those properly.

I'm going to assign myself and work on this

Assignee: nobody → nchevobbe
Status: NEW → ASSIGNED
Flags: needinfo?(lsmyth)
Flags: needinfo?(jimb)

Andy, I can't find anything related to the notation of big ints. In DevTools, would it be fine if we have the equivalent of i.toString() + "n"? We use json.stringify to send data from the server to the client, and big ints are not serializable.

Or am I missing something?

Flags: needinfo?(wingo)

Hi :) So, as per spec (https://tc39.github.io/proposal-bigint/#sec-serializejsonproperty), indeed trying to JSON.stringify a bigint throws a TypeError.

I think probably i.toString() is the most reasonable, provided you have a tag annotating that serialization as a bigint. That way to turn it back to a BigInt in devtools (if that's what you want to do), you call BigInt() on that string without stripping off the trailing "n". I'm not familiar with all of the devtools constraints though, maybe you want to keep it as a string; that's reasonable too.

If efficiency is a concern for serializing large bigint values, i.toString(16) is best -- best to have a power of two base.

Flags: needinfo?(wingo)

Thanks!

So, I filed https://github.com/firefox-devtools/debugger.html/issues/7974 to handle the client part, and already have something for the server part.

Depends on: 1531293

We add a new BigInt grip type that can be consumed by reps.
A few test cases are added to ensure this works as expected.

Pushed by nchevobbe@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/dde435d430ff Add support for BigInt in devtools; r=davidwalsh.
Status: ASSIGNED → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 68
Depends on: 1539131
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: