Skip to content

Commit

Permalink
util: throw if unreachable code is reached
Browse files Browse the repository at this point in the history
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: #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>
  • Loading branch information
Trott committed Feb 11, 2020
1 parent 9fdb6e6 commit 3eba33e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/internal/util/comparisons.js
Expand Up @@ -23,6 +23,7 @@ const {
} = primordials;

const { compare } = internalBinding('buffer');
const assert = require('internal/assert');
const types = require('internal/util/types');
const {
isAnyArrayBuffer,
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 3eba33e

Please sign in to comment.