Merge pull request #720 from ethereum/viewPure

Also treat view and pure functions as constant.
pull/1/head
yann300 7 years ago committed by GitHub
commit 2dcb41a853
  1. 8
      src/app/staticanalysis/modules/staticAnalysisCommon.js

@ -32,7 +32,7 @@ var basicRegex = {
CONTRACTTYPE: '^contract ', CONTRACTTYPE: '^contract ',
FUNCTIONTYPE: '^function \\(', FUNCTIONTYPE: '^function \\(',
EXTERNALFUNCTIONTYPE: '^function \\(.*\\).* external', EXTERNALFUNCTIONTYPE: '^function \\(.*\\).* external',
CONSTANTFUNCTIONTYPE: '^function \\(.*\\).* constant', CONSTANTFUNCTIONTYPE: '^function \\(.*\\).* (constant|view|pure)',
REFTYPE: '( storage )|(mapping\\()|(\\[\\])', REFTYPE: '( storage )|(mapping\\()|(\\[\\])',
FUNCTIONSIGNATURE: '^function \\(([^\\(]*)\\)', FUNCTIONSIGNATURE: '^function \\(([^\\(]*)\\)',
LIBRARYTYPE: '^type\\(library (.*)\\)' LIBRARYTYPE: '^type\\(library (.*)\\)'
@ -442,7 +442,11 @@ function isStateVariable (name, stateVariables) {
* @return {bool} * @return {bool}
*/ */
function isConstantFunction (node) { 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