1

I notice there has been changes made to solidity and that the word emit is now to be used in front of event triggers (to distinguish from functions being called).

However when I include these in contracts using the truffle framework to compile I get an error

PS D:\Programming\Solidity\ICO REDO> truffle compile
Error parsing D:\Programming\Solidity\ICO REDO\contracts\Token.sol: ParsedContract.sol:75:22: ParserError: Expected token Semicolon got 'LParen'
        emit Transfer(msg.sender, _to, _value);

Does anyone know why this is, or how I can get these contracts to compile with the emit word being used or should I just omit it and move on (is this now bad practice?)?

The code is:

function Token() public {
        Ownable(msg.sender);
        balances[msg.sender] = TOTALSUPPLY; 
        emit Transfer(address(0), msg.sender, TOTALSUPPLY); 
    }
2
  • Is there a semicolon missing from the line above it? Can you show us more of the code?
    – ReyHaynes
    Mar 15, 2018 at 13:36
  • I don't think so. I have added the code to the original question. Mar 15, 2018 at 14:13

1 Answer 1

5

I'm afraid that truffle is still using the old solc compiler, that's why you get that error. Indeed

$ truffle version
Truffle v4.1.3 (core: 4.1.3) //this is the last truffle version
Solidity v0.4.19 (solc-js)

You can try to update solc manually and the issue will be fixed.

$ cd /usr/local/lib/node_modules/truffle
$ npm install [email protected]

this will update your solc version and eventually you're able to compile your code correctly.

note: This will work for Mac, in Windows you might need to update the compiler in another folder note2: in case you're using an older truffle version I suggest to update it

Not the answer you're looking for? Browse other questions tagged or ask your own question.