From 296b3d6311186c7444d9d6763f8ee2d3c373dc14 Mon Sep 17 00:00:00 2001 From: Remco Bloemen Date: Thu, 20 Dec 2018 15:27:12 -0800 Subject: Throw error when source location is missing --- packages/sol-tracing-utils/src/source_maps.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'packages/sol-tracing-utils') diff --git a/packages/sol-tracing-utils/src/source_maps.ts b/packages/sol-tracing-utils/src/source_maps.ts index af0fb4035..ceb20d843 100644 --- a/packages/sol-tracing-utils/src/source_maps.ts +++ b/packages/sol-tracing-utils/src/source_maps.ts @@ -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. -- cgit