diff --git a/lib/util.js b/lib/util.js index 0483e4e0675..737ad5d0b4d 100644 --- a/lib/util.js +++ b/lib/util.js @@ -49,6 +49,7 @@ const types = internalBinding('types'); Object.assign(types, require('internal/util/types')); const { isAnyArrayBuffer, + isArgumentsObject, isDataView, isExternal, isMap, @@ -538,9 +539,13 @@ function formatValue(ctx, value, recurseTimes, ln) { if (noIterator) { braces = ['{', '}']; if (prefix === 'Object ') { - // Object fast path - if (keyLength === 0) + if (isArgumentsObject(value)) { + braces[0] = '[Arguments] {'; + if (keyLength === 0) + return '[Arguments] {}'; + } else if (keyLength === 0) { return '{}'; + } } else if (typeof value === 'function') { const name = `${constructor || tag}${value.name ? `: ${value.name}` : ''}`; diff --git a/test/parallel/test-util-inspect.js b/test/parallel/test-util-inspect.js index bdf44641212..b5ef8dca083 100644 --- a/test/parallel/test-util-inspect.js +++ b/test/parallel/test-util-inspect.js @@ -1399,3 +1399,8 @@ util.inspect(process); 'extra: true }'; assert(out === expect || out === expectAlt); } + +{ // Test argument objects. + const args = (function() { return arguments; })('a'); + assert.strictEqual(util.inspect(args), "[Arguments] { '0': 'a' }"); +}