trufflesuite / truffle

:warning: The Truffle Suite is being sunset. For information on ongoing support, migration options and FAQs, visit the Consensys blog. Thank you for all the support over the years.
https://consensys.io/blog/consensys-announces-the-sunset-of-truffle-and-ganache-and-new-hardhat?utm_source=github&utm_medium=referral&utm_campaign=2023_Sep_truffle-sunset-2023_announcement_
MIT License
14.02k stars 2.32k forks source link

ParserError: Expected identifier, got 'LParen' for constructor parameters #1463

Open roschler opened 5 years ago

roschler commented 5 years ago

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.

eggplantzzz commented 5 years ago

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

barrard commented 5 years ago

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

gnidan commented 5 years ago

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!

marxxt commented 5 years ago

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