Skip to content

Commit

Permalink
util: throw if unreachable TypedArray checking 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: #31737
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
  • Loading branch information
Trott authored and addaleax committed Feb 13, 2020
1 parent 481fa1c commit a18b437
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/internal/util/comparisons.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,11 @@ function isIdenticalTypedArrayType(a, b) {
return check(b);
}
}
return false;
/* c8 ignore next */
assert.fail(
`Unknown TypedArray type checking ${a[SymbolToStringTag]} ${a}\n` +
`and ${b[SymbolToStringTag]} ${b}`
);
}

// Notes: Type tags are historical [[Class]] properties that can be set by
Expand Down

0 comments on commit a18b437

Please sign in to comment.