Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compilation errors when using multiple pragmas and solc >= 0.7.4 #611

Closed
thegostep opened this issue Jan 31, 2021 · 9 comments
Closed

Compilation errors when using multiple pragmas and solc >= 0.7.4 #611

thegostep opened this issue Jan 31, 2021 · 9 comments

Comments

@thegostep
Copy link

image

@cgewecke
Copy link
Member

@thegostep

Are you using the latest solidity-coverage version? (0.7.14)

Can you show the relevant solidity files?

@thegostep
Copy link
Author

as far as I can tell, it is related to using pragma abicoder v2; in solo 0.7

@thegostep
Copy link
Author

Example file:

// SPDX-License-Identifier: GPL-3.0-only
pragma solidity 0.7.6;
pragma abicoder v2;

import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {IERC721} from "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import {IGeyser} from "../Geyser.sol";
import {IFactory} from "../Factory/IFactory.sol";
import {IUniversalVault} from "../UniversalVault.sol";

contract MockStakeHelper {
    function flashStake(
        address geyser,
        address vault,
        address recipient,
        uint256 amount,
        bytes calldata lockPermission,
        bytes calldata unstakePermission
    ) external {
        IGeyser(geyser).stake(vault, amount, lockPermission);
        IGeyser(geyser).unstakeAndClaim(vault, recipient, amount, unstakePermission);
    }

    function stakeBatch(
        address[] calldata geysers,
        address[] calldata vaults,
        uint256[] calldata amounts,
        bytes[] calldata permissions
    ) external {
        for (uint256 index = 0; index < vaults.length; index++) {
            IGeyser(geysers[index]).stake(vaults[index], amounts[index], permissions[index]);
        }
    }
}

@thegostep
Copy link
Author

Are you using the latest solidity-coverage version? (0.7.14)

yessir

@cgewecke
Copy link
Member

Ah it might be a bug introduced in that version - some logic was added to support file level function definitions and it might not handle multiple pragmas correctly.

Could you see if downgrading to 0.7.13 fixes?

@thegostep
Copy link
Author

Could you see if downgrading to 0.7.13 fixes?

Indeed - downgrading fixed it!

@cgewecke
Copy link
Member

Ok sweet - thanks for reporting.

@cgewecke cgewecke changed the title compilation errors thrown on coverage Compilation errors when using multiple pragmas and solc >= 0.7.4 Jan 31, 2021
@giosdas
Copy link

giosdas commented Feb 15, 2021

Hello
To help people to found this issue and save time I report here the full stacktrace in text format:

CompileError: /home/user/Projects/smart-contracts/.coverage_contracts/TokenContract.sol:3:1: DeclarationError: Function with same name and parameter types defined twice.
function c_0x56fb40c0(bytes32 c__0x56fb40c0) pure {}
^--------------------------------------------------^
/home/user/Projects/smart-contracts/.coverage_contracts/TokenContract.sol:6:1: Other declaration is here:
function c_0x56fb40c0(bytes32 c__0x56fb40c0) pure {}
^--------------------------------------------------^

Compilation failed. See above.
	at run (/home/user/Projects/smart-contracts/node_modules/truffle/build/webpack:/packages/compile-solidity/run.js:53:1)
	at Object.sourcesWithDependencies (/home/user/Projects/smart-contracts/node_modules/truffle/build/webpack:/packages/compile-solidity/index.js:121:58)
	at all (/home/user/Projects/smart-contracts/node_modules/truffle/build/webpack:/packages/compile-solidity/index.js:61:1)
	at /home/user/Projects/smart-contracts/node_modules/truffle/build/webpack:/packages/workflow-compile/legacy/index.js:98:31
	at async Promise.all (index 0)
	at Object.compile (/home/user/Projects/smart-contracts/node_modules/truffle/build/webpack:/packages/workflow-compile/legacy/index.js:50:1)
	at plugin (/home/user/Projects/smart-contracts/node_modules/solidity-coverage/plugins/truffle.plugin.js:97:5)

Regards

@cgewecke
Copy link
Member

@giosdas Thanks for pinging. Just patched this in 0.7.15. Please lmk if you're still seeing issues after upgrading

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants