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 <me@gus.host>
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
Reviewed-By: Yosuke Furukawa <yosuke.furukawa@gmail.com>
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This commit is contained in:
Rich Trott authored and Shelley Vohr committed 2020-02-17 12:38:58 -08:00
1 parent 6be51296e4
commit 9f9edc2c78
1 file changed
+3 -1
+3 -1
View File
@@ -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) {