From e6c64bf0c79cb07d5041bfbfbcc8d571315ea5fe Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Fri, 26 Mar 2021 20:18:06 -0700 Subject: [PATCH] util: remove unreachable inspect code Convert invariant from if statement to an assertion. The condition is believed to be impossible to trigger. PR-URL: https://github.com/nodejs/node/pull/37941 Reviewed-By: Colin Ihrig Reviewed-By: James M Snell --- lib/internal/util/inspect.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/internal/util/inspect.js b/lib/internal/util/inspect.js index ff59a05e0df..fd3bef5d63e 100644 --- a/lib/internal/util/inspect.js +++ b/lib/internal/util/inspect.js @@ -1438,9 +1438,7 @@ function formatNamespaceObject(keys, ctx, value, recurseTimes) { output[i] = formatProperty(ctx, value, recurseTimes, keys[i], kObjectType); } catch (err) { - if (!(isNativeError(err) && err.name === 'ReferenceError')) { - throw err; - } + assert(isNativeError(err) && err.name === 'ReferenceError'); // Use the existing functionality. This makes sure the indentation and // line breaks are always correct. Otherwise it is very difficult to keep // this aligned, even though this is a hacky way of dealing with this.