BigInt values print as "null" in the console
Categories
(DevTools :: Console, defect, P1)
Tracking
(firefox68 fixed)
| 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
| Assignee | ||
Comment 1•7 years ago
|
||
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).
| Assignee | ||
Updated•7 years ago
|
| Reporter | ||
Updated•7 years ago
|
| Reporter | ||
Comment 2•7 years ago
|
||
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.
| Assignee | ||
Comment 3•7 years ago
|
||
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 | ||
Comment 4•7 years ago
|
||
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?
| Reporter | ||
Comment 5•7 years ago
|
||
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.
| Assignee | ||
Comment 6•7 years ago
|
||
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.
| Assignee | ||
Comment 7•7 years ago
|
||
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.
Comment 9•7 years ago
|
||
| bugherder | ||
Comment 11•7 years ago
|
||
Description
•