From 4601ea1e1397b552e5509ed79e826dcca198fae7 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. --- lib/internal/util/comparisons.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/internal/util/comparisons.js b/lib/internal/util/comparisons.js index 917de00918e028..ac901b7ae29cb3 100644 --- a/lib/internal/util/comparisons.js +++ b/lib/internal/util/comparisons.js @@ -23,6 +23,7 @@ const { } = primordials; const { compare } = internalBinding('buffer'); +const assert = require('internal/assert'); const types = require('internal/util/types'); const { isAnyArrayBuffer, @@ -145,7 +146,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