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 authored and codebytere committed Feb 17, 2020
1 parent 6be5129 commit 9f9edc2
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/internal/util/comparisons.js
Original file line number Diff line number Diff line change
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 9f9edc2

Please sign in to comment.