vscode-solidity: Unreachable Code

    function payInterest(uint256 amount) public payable {
        uint256 interest = calculateInterestAmount(amount);
        require(
            msg.value == interest,
            "Not the entire interest amount deposited"
        );
        interestPaid[msg.sender][amount] = true;
    }

The tool throws an unreachable code error at the require statement and the statement following it. calculateInterestAmount returns just the number 10.

Also, the code is working fine in the truffle test suits.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 29 (13 by maintainers)

Most upvoted comments

Confirmed, after restarting VS Code I got 0.8.6. Cache issues remain one of the major challenges in modern software engineering 😜

Great. I created an issue on our side to fix it in a more permanent manner (https://github.com/ethereum/solidity/issues/11572). The problem is that outright disabling caching for this file might not be a good idea (it got 5 TB of traffic last month) so we might have to modify our mirroring to just invalidate stuff after every update.

@cameel @pcaversaccio the cache is cleared now, (web server) it is working on my end.

You will need to restart vscode to get the “new” latest, or change version and go back to “latest” to refresh it as it will be kept in memory…

Or select it from the remote option. image

I think is something is getting cached, when dowloading it from the remote source, although I am ok doing it directly.

Yes, those are the testing ones. Edit: sorted now…

@pcaversaccio it is released now.

This is unfortunately a bug in solc 0.8.5: https://github.com/ethereum/solidity/issues/11522. The code the compiler generates is correct, it’s just the analysis that incorrectly detects some calls to internal library functions as always reverting and issues a spurious warning. We already have a fix and we’re going to release it as 0.8.6 very soon.