[Ethereum] ParserError: Expected identifier, got ‘LParen’ constructor() public {

truffletruffle-compile

i don't know why i get this problem, anybody who can helps thanks a lot

pragma solidity ^0.4.21;

contract MathContract {
function mulAtoB(uint a, uint b) pure public returns(uint) {
return a * b;
}
}

Error parsing /Users/yuwei/Desktop/1110/demo1/abcd/contracts/Migrations.sol: ParsedContract.sol:7:14: ParserError: Expected identifier, got 'LParen'
constructor() public {

YuweideMacBook-Air:abcd yuwei$ truffle version
Truffle v4.1.4 (core: 4.1.4)
Solidity v0.4.21 (solc-js)

Best Answer

The code you provided works just fine, assuming you have the right compiler version.

To verify, you can just copy+paste the code in Remix https://remix.ethereum.org and change the first line to be pragma solidity ^0.5.1; as that's the default compiler in Remix (I think).

Related Topic