Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Simplify/fix when to check for designated invalid function #5661

Merged
merged 1 commit into from
Oct 28, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 7 additions & 10 deletions packages/source-map-utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down