Account for empty initialization in loops

This commit is contained in:
Andre Medeiros 2018-10-02 12:50:07 -04:00 committed by Pascal Precht
parent f79834a30d
commit bf7f4db179
No known key found for this signature in database
GPG Key ID: 0EE28D8D6FD85D7D
1 changed files with 7 additions and 5 deletions

View File

@ -249,18 +249,20 @@ class ContractSource {
let sourceMap = new SourceMap(node.src);
let bodySourceMap = new SourceMap(node.body.src);
let forLoopDeclaration = sourceMap.subtract(bodySourceMap).toString();
let initializationLocation = this.sourceMapToLocations(node.initializationExpression.src);
location = this.sourceMapToLocations(forLoopDeclaration);
let markExpression = node.initializationExpression || node.loopExpression;
let expressionLocation = this.sourceMapToLocations(markExpression.src);
if(!sourceMapToNodeType[markExpression.src]) sourceMapToNodeType[markExpression.src] = [];
sourceMapToNodeType[markExpression.src].push({type: 's', id: node.id, body: {loc: location}});
markLocations = [expressionLocation];
coverage.s[node.id] = 0;
coverage.statementMap[node.id] = location;
if(!sourceMapToNodeType[node.initializationExpression.src]) sourceMapToNodeType[node.initializationExpression.src] = [];
sourceMapToNodeType[node.initializationExpression.src].push({type: 's', id: node.id, body: {loc: location}});
children = node.body.statements;
markLocations = [initializationLocation];
break;
}