From 45cdc134cd3218fa58877f1c8a5d4b840b0cd4c0 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 fed88e963a178c..a22f1e7a1b6e9b 100644 --- a/lib/internal/util/inspect.js +++ b/lib/internal/util/inspect.js @@ -1412,9 +1412,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.