Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

util: faulty inspect output #15288

Closed
BridgeAR opened this issue Sep 9, 2017 · 3 comments
Closed

util: faulty inspect output #15288

BridgeAR opened this issue Sep 9, 2017 · 3 comments
Labels
util Issues and PRs related to the built-in util module.

Comments

@BridgeAR
Copy link
Member

BridgeAR commented Sep 9, 2017

  • Version: all
  • Platform: all
  • Subsystem: util
const a = []
a["00"] = true
Object.keys(a)
// [ '00' ]
util.inspect(a)
// Node.js < 8.4 will log
// '[  ]'
// Node.js 8.4 and master will log
// '[ true ]'
// It should be
// '[ \'00\': true ]'
@BridgeAR BridgeAR added the util Issues and PRs related to the built-in util module. label Sep 9, 2017
@BridgeAR
Copy link
Member Author

BridgeAR commented Sep 9, 2017

This will be fixed by #14881

@addaleax
Copy link
Member

addaleax commented Sep 9, 2017

Btw, not sure whether your patch will fix this as well, but on master:

> a = []
[]
> a[10000000000000] = true // not a valid array index
true
> a
[  ]
> a[0] = true
true
> a
[ true ]
> a[10] = true
true
> a
[ true, <9 empty items>, true, <9999999999989 empty items>, true ]

@BridgeAR
Copy link
Member Author

BridgeAR commented Sep 9, 2017

This is the output with my patch. It is better but still not correct. I add a patch for that as well.

> a = []
[]
> a[10000000000000] = true // not a valid array index
true
> a
[ '10000000000000': true ]
> a[0] = true
true
> a
[ true, '10000000000000': true ]
> a[10] = true
true
> a
[ true, <9 empty items>, true, <9999999999989 empty items>, true ]

BridgeAR added a commit to BridgeAR/node that referenced this issue Sep 14, 2017
The main optimizations are
- Removed visibleKeys
- Removed proxy cache
- Removed Object.assign
- No key concatenating anymore
- No key recalculating anymore
- Improved indentation logic
- Improved string escape logic
- Added many fast paths
- Optimized code branches a lot
- Optimized (boxed) primitive handling
- Inline code if possible
- Only check extra keys if necessary
- Guard against unnecessary more expensive calls

This also fixes a bug with special array number keys as e.g. "00".

Besides that there were lots of smaller optimizations, the
code got a bit cleaned up and a few more tests got in.

Fixes nodejs#15288
BridgeAR added a commit to BridgeAR/node that referenced this issue Sep 14, 2017
This fixes a issue brought up in 15288.

Ref nodejs#15288
BridgeAR added a commit that referenced this issue Sep 15, 2017
This fixes a issue brought up in #15288.

PR-URL: #14881
Refs: #15288
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
addaleax pushed a commit to addaleax/ayo that referenced this issue Sep 17, 2017
The main optimizations are
- Removed visibleKeys
- Removed proxy cache
- Removed Object.assign
- No key concatenating anymore
- No key recalculating anymore
- Improved indentation logic
- Improved string escape logic
- Added many fast paths
- Optimized code branches a lot
- Optimized (boxed) primitive handling
- Inline code if possible
- Only check extra keys if necessary
- Guard against unnecessary more expensive calls

This also fixes a bug with special array number keys as e.g. "00".

Besides that there were lots of smaller optimizations, the
code got a bit cleaned up and a few more tests got in.

PR-URL: nodejs/node#14881
Fixes: nodejs/node#15288
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
addaleax pushed a commit to addaleax/ayo that referenced this issue Sep 17, 2017
This fixes a issue brought up in #15288.

PR-URL: nodejs/node#14881
Refs: nodejs/node#15288
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
BridgeAR added a commit to BridgeAR/node that referenced this issue Sep 20, 2017
The main optimizations are
- Removed visibleKeys
- Removed proxy cache
- Removed Object.assign
- No key concatenating anymore
- No key recalculating anymore
- Improved indentation logic
- Improved string escape logic
- Added many fast paths
- Optimized code branches a lot
- Optimized (boxed) primitive handling
- Inline code if possible
- Only check extra keys if necessary
- Guard against unnecessary more expensive calls

This also fixes a bug with special array number keys as e.g. "00".

Besides that there were lots of smaller optimizations, the
code got a bit cleaned up and a few more tests got in.

PR-URL: nodejs#14881
Fixes: nodejs#15288
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
BridgeAR added a commit to BridgeAR/node that referenced this issue Sep 20, 2017
This fixes a issue brought up in nodejs#15288.

PR-URL: nodejs#14881
Refs: nodejs#15288
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
jasnell pushed a commit that referenced this issue Sep 21, 2017
The main optimizations are
- Removed visibleKeys
- Removed proxy cache
- Removed Object.assign
- No key concatenating anymore
- No key recalculating anymore
- Improved indentation logic
- Improved string escape logic
- Added many fast paths
- Optimized code branches a lot
- Optimized (boxed) primitive handling
- Inline code if possible
- Only check extra keys if necessary
- Guard against unnecessary more expensive calls

This also fixes a bug with special array number keys as e.g. "00".

Besides that there were lots of smaller optimizations, the
code got a bit cleaned up and a few more tests got in.

PR-URL: #14881
Fixes: #15288
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
jasnell pushed a commit that referenced this issue Sep 21, 2017
This fixes a issue brought up in #15288.

PR-URL: #14881
Refs: #15288
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Qard pushed a commit to Qard/ayo that referenced this issue Sep 21, 2017
The main optimizations are
- Removed visibleKeys
- Removed proxy cache
- Removed Object.assign
- No key concatenating anymore
- No key recalculating anymore
- Improved indentation logic
- Improved string escape logic
- Added many fast paths
- Optimized code branches a lot
- Optimized (boxed) primitive handling
- Inline code if possible
- Only check extra keys if necessary
- Guard against unnecessary more expensive calls

This also fixes a bug with special array number keys as e.g. "00".

Besides that there were lots of smaller optimizations, the
code got a bit cleaned up and a few more tests got in.

PR-URL: nodejs/node#14881
Fixes: nodejs/node#15288
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Qard pushed a commit to Qard/ayo that referenced this issue Sep 21, 2017
This fixes a issue brought up in #15288.

PR-URL: nodejs/node#14881
Refs: nodejs/node#15288
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
util Issues and PRs related to the built-in util module.
Projects
None yet
Development

No branches or pull requests

2 participants