0

My question is how is it possible to have such error:

Error (9553): Invalid type for argument in function call. Invalid implicit conversion from enum CoinType to enum CoinType requested.
  --> test/foundry/zrc20_interface.t.sol:16:46:
   |
16 |         zrc20 = new ZRC20("TOKEN","TKN",18,1,cointype,0,address(systemContract));
   |                                              ^^^^^^^^

This is enum in Interface.sol

    enum CoinType {
        Zeta,
        Gas,
        ERC20
    }

This is a test case using Foundry framework

// SPDX-License-Identifier: MIT
pragma solidity 0.8.7;

import {Test, console2} from "forge-std/Test.sol";

import { ZRC20 } from "../../contracts/zevm/ZRC20.sol";
import { SystemContractMock } from "../../contracts/zevm/testing/SystemContractMock.sol";
import "./Interfaces.sol";
contract zrc20_interface is Test {
    ZRC20 public zrc20;
    SystemContractMock public systemContract;
    CoinType cointype;
    function setUp() public {
        cointype = CoinType.Zeta;
        systemContract = new SystemContractMock(address(0),address(0),address(0));
        zrc20 = new ZRC20("TOKEN","TKN",18,1,cointype,0,address(systemContract));
    }

}

1 Answer 1

2

Yes I have encountered this before.The enum CoinType is defined in Interface.sol, but is Interface.sol being imported in any of ZRC20.sol or SystemContractMock.sol? . Becuase if it is then compiler is basically referencing two different memory regions. Remove the import "./Interfaces.sol"; statement and try this :

import { SystemContractMock, CoinType } from "../../contracts/zevm/testing/SystemContractMock.sol"; 

and compile again. For some reason with current version of Foundry import {X} from "..."; syntax is silently mandatory

2
  • Hmm, I will report this in Foundry Github. It would be nice to log error specifically as the current log is misleading Nov 23, 2023 at 3:00
  • 1
    I think someone may have raised an issue already, perhaps run it by foundry telegram group first. Nov 23, 2023 at 6:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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