From f4e5404b5d1f41eff751b9edb7af833185065073 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Tue, 11 Feb 2020 01:31:25 -1000 Subject: [PATCH] util: throw if unreachable TypedArray checking 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: https://github.com/nodejs/node/pull/31737 Reviewed-By: Ruben Bridgewater Reviewed-By: Anna Henningsen Reviewed-By: James M Snell Reviewed-By: Luigi Pinca --- lib/internal/util/comparisons.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/internal/util/comparisons.js b/lib/internal/util/comparisons.js index 222bb936722cb6..1598e7f9136ace 100644 --- a/lib/internal/util/comparisons.js +++ b/lib/internal/util/comparisons.js @@ -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