solidity-coverage: solc 0.4.17 compile errors for pure functions
With the truffle
4 beta 2 release which includes the solc@0.4.17
upgrade instrumented contracts containing functions decorated with view
will generate a Warning, while those marked as pure
will Error with
TypeError: Function declared as pure, but this expression (potentially) reads from the environment or state and thus requires "view".
This is due to the SC instrumented function containing events (which modify state) being present in the pure
function.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 3
- Comments: 22 (15 by maintainers)
Commits related to this issue
- Temporary mark 'pure' function as 'view' only due to https://github.com/sc-forks/solidity-coverage/issues/131 — committed to JoinColony/colonyNetwork by elenadimitrova 7 years ago
- Fix issue with imported packages with subfolders See: https://github.com/sc-forks/solidity-coverage/issues/131#issuecomment-417748614 — committed to bingen/solidity-coverage by bingen 6 years ago
- Copy .solcover.js config from AragonOS and update solidity-coverage... - See: [issue in solidity-coverage repo](https://github.com/sc-forks/solidity-coverage/issues/131#issuecomment-417793758) — committed to ottodevs/planning-app by ottodevs 6 years ago
- Update solidity-coverage dep and delete unused external minime - We use the same in test-helpers - The update of solidity-coverage is motivated by this [fix](https://github.com/sc-forks/solidity-cove... — committed to ottodevs/planning-app by ottodevs 6 years ago
- chore: add nohoist for @openzeppelin/contracts-ethereum-package * https://github.com/sc-forks/solidity-coverage/issues/131 * https://github.com/sc-forks/solidity-coverage/issues/264 — committed to sablier-labs/v1-protocol by PaulRBerg 5 years ago
- Fix issue with imported packages with subfolders See: https://github.com/sc-forks/solidity-coverage/issues/131#issuecomment-417748614 — committed to elitexpro/solidity-coverage by elitexpro 6 years ago
I seem to be facing the same issue with
0.5.8
.MyContract.sol
inherits fromopenzeppelin-zos/contracts/token/ERC20/ERC20.sol
and implments the allowance function with the same signature.Thanks @cgewecke Compilation failed for me in the following scenario: Contract inhering from another which lives outside the
/contracts
folder, e.g. a git submodule library for me specifically it looks like this:This generates compile error:
I still have this issue on 0.5.7.
I have a
tokenURI()
function that override OpenZeppeline’s ERC721Token.sol:Then I got this error:
tokenURI()
I wrote follow exactly the same as the one in ERC721.sol and hasview
, but seems solidity-coverage ignore it and reporting the error…@cgewecke Yes, it works. I’m going to submit a PR with a workaround that worked for me too.
hey @cgewecke I’m having the same problem here: https://github.com/aragon/aragon-apps/pull/425/commits/2da188ff9351779a7dc244232421881d1eb251a0 take
apps/vault
, which is kind of simple. I tried your suggestion, so modified.solcover.js
to:And then I run
./node_modules/.bin/solidity-coverage .
, but I get the following error:Could it be due to the folder structure of the package, with 2 subfolders? I’m seeing that under
coverageEnv
it appears as justos
instead of@aragon/os
.@sweatyc I got it to run by adding a
.solcover.js
with the following contents. Basically same as the previous comment:There’s an additional issue in the landpot-contracts where there is a migrations file that doesn’t work (2) but just deleted it and everything was fine.
@elenadimitrova Thanks, yes that makes sense.
Opening a separate issue for this.Reopening. We just need to globalize the replace for.sols
…For now, I think the only way to solve this is to remove the
pure
andview
decorators during instrumentation.