mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Warn about functions named "constructor".
This commit is contained in:
parent
cd17c37fe6
commit
4895864302
@ -1,8 +1,9 @@
|
|||||||
### 0.4.23 (unreleased)
|
### 0.4.23 (unreleased)
|
||||||
|
|
||||||
Features:
|
Features:
|
||||||
* SMTChecker: Integration with CVC4 SMT solver
|
|
||||||
* Build system: Support Ubuntu Bionic.
|
* Build system: Support Ubuntu Bionic.
|
||||||
|
* SMTChecker: Integration with CVC4 SMT solver
|
||||||
|
* Syntax Checker: Warn about functions named "constructor".
|
||||||
|
|
||||||
Bugfixes:
|
Bugfixes:
|
||||||
* Type Checker: Do not complain about new-style constructor and fallback function to have the same name.
|
* Type Checker: Do not complain about new-style constructor and fallback function to have the same name.
|
||||||
|
@ -237,8 +237,13 @@ bool SyntaxChecker::visit(FunctionDefinition const& _function)
|
|||||||
if (v050)
|
if (v050)
|
||||||
m_errorReporter.syntaxError(_function.location(), "Functions without implementation cannot have modifiers.");
|
m_errorReporter.syntaxError(_function.location(), "Functions without implementation cannot have modifiers.");
|
||||||
else
|
else
|
||||||
m_errorReporter.warning( _function.location(), "Modifiers of functions without implementation are ignored." );
|
m_errorReporter.warning(_function.location(), "Modifiers of functions without implementation are ignored." );
|
||||||
}
|
}
|
||||||
|
if (_function.name() == "constructor")
|
||||||
|
m_errorReporter.warning(_function.location(),
|
||||||
|
"This function is named \"constructor\" but is not the constructor of the contract. "
|
||||||
|
"If you intend this to be a constructor, use \"constructor(...) { ... }\" without the \"function\" keyword to define it."
|
||||||
|
);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,5 @@
|
|||||||
|
contract C {
|
||||||
|
function constructor() public;
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// Warning: (17-47): This function is named "constructor" but is not the constructor of the contract. If you intend this to be a constructor, use "constructor(...) { ... }" without the "function" keyword to define it.
|
Loading…
Reference in New Issue
Block a user