From 64be7320fbcea81d03a4e3174fcf81251cfdea4b Mon Sep 17 00:00:00 2001 From: Harry Altman Date: Fri, 28 Oct 2022 17:12:26 -0400 Subject: [PATCH] Simplify/fix when to check for designated invalid --- packages/source-map-utils/index.js | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/packages/source-map-utils/index.js b/packages/source-map-utils/index.js index 46f6f35bafc..5aa238b421d 100644 --- a/packages/source-map-utils/index.js +++ b/packages/source-map-utils/index.js @@ -210,10 +210,14 @@ var SourceMapUtils = { .map(instruction => { debug("instruction %O", instruction); const sourceIndex = instruction.file; - //first off, a special case: if the file is -1, check for designated + const findOverlappingRange = overlapFunctions[sourceIndex]; + const ast = asts[sourceIndex]; + //first off, if we can't get the AST, check for designated //invalid and if it's not that give up - //(designated invalid gets file -1 in some Solidity versions) - if (sourceIndex === -1) { + //(note that being unable to get the AST includes the case + //of source index -1; designated invalid has source index + //-1 in some Solidity versions) + if (!ast) { if ( SourceMapUtils.isDesignatedInvalid( instructions, @@ -232,13 +236,6 @@ var SourceMapUtils = { return {}; } } - //now we proceed with the normal case - const findOverlappingRange = overlapFunctions[sourceIndex]; - const ast = asts[sourceIndex]; - if (!ast) { - //if we can't get the ast... filter it out I guess - return {}; - } const range = SourceMapUtils.getSourceRange(instruction); let { node, pointer } = SourceMapUtils.findRange( findOverlappingRange,