Merge pull request #1313 from ethereum/fix/#1108

delete from mapping will not show warning
pull/7/head
yann300 5 years ago committed by GitHub
commit f762684c2f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      remix-analyzer/src/solidity-analyzer/modules/deleteFromDynamicArray.js
  2. 10
      remix-analyzer/src/solidity-analyzer/modules/staticAnalysisCommon.js

@ -8,7 +8,7 @@ function deleteFromDynamicArray () {
}
deleteFromDynamicArray.prototype.visit = function (node) {
if (common.isDeleteFromDynamicArray(node)) this.relevantNodes.push(node)
if (common.isDeleteFromDynamicArray(node) && !common.isMappingIndexAccess(node.children[0])) this.relevantNodes.push(node)
}
deleteFromDynamicArray.prototype.report = function (compilationResults) {

@ -535,6 +535,15 @@ function isIndexAccess (node) {
return node && node.name === 'IndexAccess'
}
/**
* True if node is the access of a mapping index
* @node {ASTNode} node to check for
* @return {bool}
*/
function isMappingIndexAccess (node) {
return isIndexAccess(node) && node.children && node.children[0].attributes.type.startsWith('mapping')
}
/**
* True if call to code within the current contracts context including (delegate) library call
* @node {ASTNode} some AstNode
@ -1103,6 +1112,7 @@ module.exports = {
isSpecialVariableAccess: isSpecialVariableAccess,
isDynamicArrayAccess: isDynamicArrayAccess,
isIndexAccess: isIndexAccess,
isMappingIndexAccess: isMappingIndexAccess,
isSubScopeWithTopLevelUnAssignedBinOp: isSubScopeWithTopLevelUnAssignedBinOp,
hasFunctionBody: hasFunctionBody,
isInteraction: isInteraction,

Loading…
Cancel
Save