mirror of
https://github.com/microsoft/vscode.git
synced 2026-07-05 22:36:01 +01:00
tracer: fix stringifying arrays (#2353)
issue: The Array.isArray(value) check at line 113 will never be reached because arrays are also objects in JavaScript. The earlier check at line 105 (typeof value === 'object') will catch arrays first and pass them to stringifyObj(), making the array-specific handling code unreachable.
This commit is contained in:
committed by
GitHub
parent
e63188cacb
commit
6843bcd5ef
@@ -102,10 +102,6 @@ export class Tracer implements ITracer {
|
||||
return value;
|
||||
}
|
||||
|
||||
if (typeof value === 'object') {
|
||||
return stringifyObj(value);
|
||||
}
|
||||
|
||||
if (typeof value === 'function') {
|
||||
return value.name ? `[Function: ${value.name}]` : '[Function]';
|
||||
}
|
||||
@@ -114,6 +110,10 @@ export class Tracer implements ITracer {
|
||||
return `[${value.map(v => this.stringify(v)).join(', ')}]`;
|
||||
}
|
||||
|
||||
if (typeof value === 'object') {
|
||||
return stringifyObj(value);
|
||||
}
|
||||
|
||||
const valueToString = value.toString();
|
||||
if (valueToString && valueToString !== '[object Object]') {
|
||||
return valueToString;
|
||||
|
||||
Reference in New Issue
Block a user