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

keyword "interface" not accepted (compile fails) #560

Closed d10r closed 7 years ago

d10r commented 7 years ago

This has already been asked in the Gitter channel by others, but not answered (as far as I could see).


Issue

Compiling files containing interface definitions fails with

SyntaxError: Error parsing /somepath/somefile.sol: Expected "contract", "import", "library", "pragma", "using", comment, end of input, end of line, or whitespace but "i" found.

Steps to Reproduce

Create a solidity file containing an interface definition, e.g.

interface IDummy {
    function dummy();
}

and try to have it compiled with truffle compile.

Expected Behavior

Since the interface keyword is supported since Solidity 0.4.11 (seeChangelog), truffle - which is using solc 0.4.15 - should recognize it.

In Remix IDE, the behaviour is as expected. If the compiler version is at least 0.4.11, files with interface definitions compile.

Actual Results

$ truffle compile
SyntaxError: Error parsing /home/didi/src/p4p/blockchain/contracts/PlayToken.sol: Expected "contract", "import", "library", "pragma", "using", comment, end of input, end of line, or whitespace but "i" found. Line: 4, Column: 1
    at peg$buildStructuredError (/home/didi/.nvm/versions/node/v6.11.0/lib/node_modules/truffle/build/cli.bundled.js:181971:12)
    at Object.peg$parse [as parse] (/home/didi/.nvm/versions/node/v6.11.0/lib/node_modules/truffle/build/cli.bundled.js:185570:11)
    at Object.parse (/home/didi/.nvm/versions/node/v6.11.0/lib/node_modules/truffle/build/cli.bundled.js:83782:23)
    at /home/didi/.nvm/versions/node/v6.11.0/lib/node_modules/truffle/build/cli.bundled.js:59136:36
    at /home/didi/.nvm/versions/node/v6.11.0/lib/node_modules/truffle/build/cli.bundled.js:49114:5
    at /home/didi/.nvm/versions/node/v6.11.0/lib/node_modules/truffle/build/cli.bundled.js:60660:16
    at next (/home/didi/.nvm/versions/node/v6.11.0/lib/node_modules/truffle/build/cli.bundled.js:69109:18)
    at /home/didi/.nvm/versions/node/v6.11.0/lib/node_modules/truffle/build/cli.bundled.js:49099:7
    at /home/didi/.nvm/versions/node/v6.11.0/lib/node_modules/truffle/build/cli.bundled.js:96498:5
    at /home/didi/.nvm/versions/node/v6.11.0/lib/node_modules/truffle/build/cli.bundled.js:69014:16

Environment

mrhn commented 7 years ago

Having the same problem with solc 0.4.15 also... fresh install this friday.

kevbry commented 7 years ago

Same issue.

Environment:

hotblade commented 7 years ago

Same problem.

dlocation commented 7 years ago

We must wait for update solidity-parser package that implement interface support PR has been merged yet but realease not published yet https://github.com/ConsenSys/solidity-parser/pull/68

OR You can swap to beta version of truffle.