From 3eba33eb07353b8b642792d928425b4c4977767e Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Sun, 9 Feb 2020 12:42:21 -1000 Subject: [PATCH] util: throw if unreachable code is reached If a comparison code path that is supposed to be unreachable is reached, throw. Add a c8 comment to ignore coverage for the line, as it should be unreachable. PR-URL: https://github.com/nodejs/node/pull/31712 Reviewed-By: Gus Caplan Reviewed-By: Anto Aravinth Reviewed-By: Yosuke Furukawa Reviewed-By: Yongsheng Zhang Reviewed-By: James M Snell Reviewed-By: Ruben Bridgewater Reviewed-By: Colin Ihrig --- lib/internal/util/comparisons.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/internal/util/comparisons.js b/lib/internal/util/comparisons.js index 917de00918e028..ed320995b83272 100644 --- a/lib/internal/util/comparisons.js +++ b/lib/internal/util/comparisons.js @@ -23,6 +23,7 @@ const { } = primordials; const { compare } = internalBinding('buffer'); +const assert = require('internal/assert'); const types = require('internal/util/types'); const { isAnyArrayBuffer, @@ -118,7 +119,8 @@ function isEqualBoxedPrimitive(val1, val2) { return isSymbolObject(val2) && SymbolPrototypeValueOf(val1) === SymbolPrototypeValueOf(val2); } - return false; + /* c8 ignore next */ + assert.fail(`Unknown boxed type ${val1}`); } function isIdenticalTypedArrayType(a, b) {