Truffle: ParserError: Expected identifier, got 'LParen' for constructor parameters

Created on 26 Nov 2018  路  4Comments  路  Source: trufflesuite/truffle

  • [ ] I've asked for help in the Truffle Gitter before filing this issue.

I have not asked for help yet as this requires a detailed breakdown of the problem.

I am referencing this similar issue but please note, I believe it's due to a different cause than the one hypothesized in the issue linked to below, which indicates that it was due to a "stale" copy of _solc_ existing on the user's station. I executed the same steps suggested to the user and it did _not_ solve my problem. I believe that my issue (assumption, not confirmed) has to due with my use of the new "compiler" section available with Truffle 5.0 beta to use an older compiler. I believe that Truffle _is_ using the older compile because since I added the "compiler" section with version "0.4.21" it no longer throws errors for addresses not marked as _payable_, a 5.0 specific error, even though it prints out a message indicating the 5.0 compiler is in use:

https://github.com/trufflesuite/truffle/issues/906

Here is the error I am getting since I upgraded to Truffle 5.0:

Error parsing /home/robert/Documents/GitHub/ME/ether-band-battles-work/solidity/contracts/Migrations.sol: ParsedContract.sol:7:14: ParserError: Expected identifier, got 'LParen'
  constructor() public {
             ^
Compilation failed. See above.

Truffle v5.0.0-beta.2 (core: 5.0.0-beta.2)
Solidity v0.5.0 (solc-js)
Node v8.11.1

How can I fix this? Here is the relevant section of my Truffle js file:

  compilers: {
     solc: {
       version: "0.4.21"
     }
  },
  /** Added solidity optimize in attempt to combat out of gas errors during migrates to Ganache. **/
  solc: {
    optimizer: {
      enabled: true,
      runs: 200
    }
  } 

Note, if I am correct in my analysis, this also indicates that Truffle should print out the version of _solc_ actually being used, as per the directive in Truffle.js, instead of simply printing out v0.5.0 as it appears to be doing now.

error better

Most helpful comment

Check if one of your vs Code plugin is "Solidity Extended" by beaugunderson and disable it.

All 4 comments

Hey @roschler, Is the code you are working with available anywhere?

Your truffle.js file has solc set to a version that didn't support constructor functions.
Try and bump it up to 0.4.22

This looks like not a bug, but it looks like something that could be handled much better. Leaving this open to track improving error handling in situations like this. Thanks!

Check if one of your vs Code plugin is "Solidity Extended" by beaugunderson and disable it.

Was this page helpful?
0 / 5 - 0 ratings