Skip to content

Commit c9fa2d1

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 <[email protected]> Reviewed-By: Anto Aravinth <[email protected]> Reviewed-By: Yosuke Furukawa <[email protected]> Reviewed-By: Yongsheng Zhang <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
1 parent 1db85aa commit c9fa2d1

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+
constassert=require('internal/assert');
2627
consttypes=require('internal/util/types');
2728
const{
2829
isAnyArrayBuffer,
@@ -118,7 +119,8 @@ function isEqualBoxedPrimitive(val1, val2){
118119
returnisSymbolObject(val2)&&
119120
SymbolPrototypeValueOf(val1)===SymbolPrototypeValueOf(val2);
120121
}
121-
returnfalse;
122+
/* c8 ignore next */
123+
assert.fail(`Unknown boxed type ${val1}`);
122124
}
123125

124126
functionisIdenticalTypedArrayType(a,b){

0 commit comments

Comments
(0)