Merge pull request #763 from leonardoalt/fix_analysis_constructor

Fix 'potentially should be const' for constructors in static analysis
pull/7/head
yann300 7 years ago committed by GitHub
commit d1948a266e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      remix-solidity/src/analysis/modules/constantFunctions.js
  2. 12
      remix-solidity/src/analysis/modules/staticAnalysisCommon.js

@ -34,7 +34,7 @@ function report (contracts, multipleContractsWithSameName) {
contracts.forEach((contract) => { contracts.forEach((contract) => {
contract.functions.forEach((func) => { contract.functions.forEach((func) => {
if (common.isPayableFunction(func.node)) { if (common.isPayableFunction(func.node) || common.isConstructor(func.node)) {
func.potentiallyshouldBeConst = false func.potentiallyshouldBeConst = false
} else { } else {
func.potentiallyshouldBeConst = checkIfShouldBeConstant(common.getFullQuallyfiedFuncDefinitionIdent(contract.node, func.node, func.parameters), func.potentiallyshouldBeConst = checkIfShouldBeConstant(common.getFullQuallyfiedFuncDefinitionIdent(contract.node, func.node, func.parameters),

@ -520,6 +520,17 @@ function isPayableFunction (node) {
) )
} }
/**
* True if is constructor
* @node {ASTNode} some AstNode
* @return {bool}
*/
function isConstructor (node) {
return isFunctionDefinition(node) && (
node.attributes.isConstructor === true
)
}
/** /**
* True if unary increment operation * True if unary increment operation
* @node {ASTNode} some AstNode * @node {ASTNode} some AstNode
@ -857,6 +868,7 @@ module.exports = {
isContractDefinition: isContractDefinition, isContractDefinition: isContractDefinition,
isConstantFunction: isConstantFunction, isConstantFunction: isConstantFunction,
isPayableFunction: isPayableFunction, isPayableFunction: isPayableFunction,
isConstructor: isConstructor,
isInlineAssembly: isInlineAssembly, isInlineAssembly: isInlineAssembly,
isNewExpression: isNewExpression, isNewExpression: isNewExpression,
isReturn: isReturn, isReturn: isReturn,

Loading…
Cancel
Save