Syntax error when using the new constructor syntax
See original GitHub issueFrom solidity v0.4.22 onwards, the new syntax for constructors is:
pragma solidity ^0.4.23;
contract MyContract {
constructor() public {
// initialize things
}
}
The previous version using the contract’s name is now deprecated:
pragma solidity ^0.4.23;
contract MyContract {
function MyContract() public {
// initialize things
}
}
On VSCode using this extension, I get the following error when using the new syntax:
ParserError: Expected identifier, got 'LParen' constructor() public { ^
.
When compiling my contracts with solc
directly or with truffle
I get deprecation warnings when using the old syntax, and the new one works well.
Issue Analytics
- State:
- Created 5 years ago
- Comments:11 (6 by maintainers)
Top Results From Across the Web
SyntaxError() constructor - JavaScript - MDN Web Docs
SyntaxError() constructor. The SyntaxError constructor creates a new error object that represents an error when trying to interpret syntactically invalid code.
Read more >Syntax Error when call Error.constructor with a string including ...
First off, Error.constructor is actually Object.constructor : > Error.constructor === Object.constructor true. Second, Object.constructor ...
Read more >SyntaxError - JavaScript: The Definitive Guide, 6th Edition [Book]
When the SyntaxError() constructor is called as a function, without the new operator, it behaves just as it does when called with the...
Read more >SML/NJ Error Messages
This error occurs when type constructors with incompatible equality properties are equated by sharing constraints. When this happens, the signature is not ...
Read more >Syntax Error in CONSTRUCTOR method - but Why?
In the book "Next Generation ABAP Development" (by Rich Heilman and Thomas Jung) there are examples that do use Private constructors just like...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It has been upgraded and released now. Please reopen if you see any issues. Thanks again @duaraghav8 !!
@tsauvajon that is an issue with the linter https://github.com/duaraghav8/Solium/issues/198. I’ll keep this open to update it ASAP as it gets added to solium.