From da1f2434f13227bddbaf047d5bf6160d936fdddb Mon Sep 17 00:00:00 2001 From: chriseth Date: Fri, 25 Aug 2017 10:45:29 +0200 Subject: [PATCH] Also treat view and pure functions as constant. --- src/app/staticanalysis/modules/staticAnalysisCommon.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/app/staticanalysis/modules/staticAnalysisCommon.js b/src/app/staticanalysis/modules/staticAnalysisCommon.js index 99a2a9ee7b..b9ec093bb6 100644 --- a/src/app/staticanalysis/modules/staticAnalysisCommon.js +++ b/src/app/staticanalysis/modules/staticAnalysisCommon.js @@ -32,7 +32,7 @@ var basicRegex = { CONTRACTTYPE: '^contract ', FUNCTIONTYPE: '^function \\(', EXTERNALFUNCTIONTYPE: '^function \\(.*\\).* external', - CONSTANTFUNCTIONTYPE: '^function \\(.*\\).* constant', + CONSTANTFUNCTIONTYPE: '^function \\(.*\\).* (constant|view|pure)', REFTYPE: '( storage )|(mapping\\()|(\\[\\])', FUNCTIONSIGNATURE: '^function \\(([^\\(]*)\\)', LIBRARYTYPE: '^type\\(library (.*)\\)' @@ -442,7 +442,11 @@ function isStateVariable (name, stateVariables) { * @return {bool} */ function isConstantFunction (node) { - return isFunctionDefinition(node) && node.attributes.constant === true + return isFunctionDefinition(node) && ( + node.attributes.constant === true || + node.attributes.stateMutability === 'view' || + node.attributes.stateMutability === 'pure' + ) } /**