Throw error when source location is missing

This commit is contained in:
Remco Bloemen
2018-12-20 15:27:12 -08:00
committed by Leonid Logvinov
parent 4d03c3035c
commit 296b3d6311

View File

@@ -67,13 +67,17 @@ export function parseSourceMap(
fileIndex,
};
if (parsedEntry.fileIndex !== -1 && !_.isUndefined(locationByOffsetByFileIndex[parsedEntry.fileIndex])) {
const locationByOffset = locationByOffsetByFileIndex[parsedEntry.fileIndex];
const sourceRange = {
location: {
start: locationByOffsetByFileIndex[parsedEntry.fileIndex][parsedEntry.offset],
end: locationByOffsetByFileIndex[parsedEntry.fileIndex][parsedEntry.offset + parsedEntry.length],
start: locationByOffset[parsedEntry.offset],
end: locationByOffset[parsedEntry.offset + parsedEntry.length],
},
fileName: sources[parsedEntry.fileIndex],
};
if (sourceRange.location.start === undefined || sourceRange.location.end === undefined) {
throw new Error(`Error while processing sourcemap: location out of range in ${sourceRange.fileName}`);
}
instructionIndexToSourceRange[i] = sourceRange;
} else {
// Some assembly code generated by Solidity can't be mapped back to a line of source code.