Skip to content

Commit 9f9edc2

Browse files
Trottcodebytere
authored andcommitted
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: #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>
1 parent 6be5129 commit 9f9edc2

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/internal/util/comparisons.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ const {
2323
} = primordials;
2424

2525
const { compare } = internalBinding('buffer');
26+
const assert = require('internal/assert');
2627
const types = require('internal/util/types');
2728
const {
2829
isAnyArrayBuffer,
@@ -118,7 +119,8 @@ function isEqualBoxedPrimitive(val1, val2) {
118119
return isSymbolObject(val2) &&
119120
SymbolPrototypeValueOf(val1) === SymbolPrototypeValueOf(val2);
120121
}
121-
return false;
122+
/* c8 ignore next */
123+
assert.fail(`Unknown boxed type ${val1}`);
122124
}
123125

124126
function isIdenticalTypedArrayType(a, b) {

0 commit comments

Comments
 (0)