diff --git a/lib/modules/coverage/contract_source.js b/lib/modules/coverage/contract_source.js index 734ee89fc..44b518ce4 100644 --- a/lib/modules/coverage/contract_source.js +++ b/lib/modules/coverage/contract_source.js @@ -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; }