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

Contract name and filename collisions #1488

Closed
1 of 2 tasks
antonper opened this issue May 4, 2022 · 4 comments
Closed
1 of 2 tasks

Contract name and filename collisions #1488

antonper opened this issue May 4, 2022 · 4 comments
Assignees
Labels
C-forge Command: forge Cmd-forge-build Command: forge build P-normal Priority: normal T-bug Type: bug
Milestone

Comments

@antonper
Copy link

antonper commented May 4, 2022

Component

Forge

Have you ensured that all of these are up to date?

  • Foundry
  • Foundryup

What version of Foundry are you on?

forge 0.2.0 (a97090d 2022-05-02T00:04:10.711117948+00:00)

What command(s) is the bug in?

forge build

Operating System

Linux

Describe the bug

File structure:

├── src
│   ├── a.sol
│   └── inner
│       └── a.sol

src/a.sol

// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;

contract A {
  function bar() public {
  }
}

src/inner/a.sol

// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;

contract A {
  function bar() public {
  }
}
contract B {
  function foo() public {
  }
}

After running forge build I have following file structure:

├── out
│   └── a.sol
│       ├── A.json
│       └── B.json

The content of out json files corresponds to inner/a.sol. No data will be in out folder for the src/a.sol file.
Similar thing happens if A inside inner/a.sol is an interface. This is a bit unusual to define same contracts in files with same names, but may be something like a warning is a good option here.

@antonper antonper added the T-bug Type: bug label May 4, 2022
@onbjerg onbjerg added this to Foundry May 4, 2022
@onbjerg onbjerg moved this to Todo in Foundry May 4, 2022
@onbjerg onbjerg added C-forge Command: forge P-normal Priority: normal Cmd-forge-build Command: forge build labels May 5, 2022
@mattsse mattsse self-assigned this May 20, 2022
@mattsse
Copy link
Member

mattsse commented May 20, 2022

sorry for the wait, investigating this and add a fix to prevent collisions where count((filename, contractname)) > 1

@0xalpharush
Copy link
Contributor

Can this be prioritized? Several users of slither have encountered this collision error, and there's not an easy way to bypass aside from switching to hardhat.

@mattsse
Copy link
Member

mattsse commented Jul 18, 2022

bumping, trying to fix this asap

@mattsse
Copy link
Member

mattsse commented Aug 3, 2022

this was fixed with gakonst/ethers-rs#1487 gakonst/ethers-rs#1491

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-forge Command: forge Cmd-forge-build Command: forge build P-normal Priority: normal T-bug Type: bug
Projects
Archived in project
Development

No branches or pull requests

4 participants