Also treat view and pure functions as constant.

pull/1/head
chriseth 7 years ago committed by yann300
parent 1ea66f16c9
commit da1f2434f1
  1. 8
      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'
)
}
/**

Loading…
Cancel
Save