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

forge flatten with renamed interface import does not compile #3265

Closed
2 tasks done
chad-js opened this issue Sep 19, 2022 · 3 comments · Fixed by #6936
Closed
2 tasks done

forge flatten with renamed interface import does not compile #3265

chad-js opened this issue Sep 19, 2022 · 3 comments · Fixed by #6936
Assignees
Labels
C-forge Command: forge Cmd-forge-flatten Command: forge flatten T-bug Type: bug

Comments

@chad-js
Copy link
Contributor

chad-js commented Sep 19, 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 (084ef3d 2022-09-19T00:04:35.98318Z)

What command(s) is the bug in?

forge flatten

Operating System

macOS (Apple Silicon)

Describe the bug

If I have a contract using a named import of an interface, such as

import { IERC20 as MyIERC20 } from "src/interfaces/IERC20.sol";

forge flatten on that file results in output that includes the IERC20 interface, and the contract using the named import. Since the contract uses the named import MyIERC20, and the flattened file includes interface IERC20 but not interface MyIERC20, forge build fails with DeclarationError: Identifier not found or not unique.

This seems related to #1440

@chad-js chad-js added the T-bug Type: bug label Sep 19, 2022
@gakonst gakonst added this to Foundry Sep 19, 2022
@gakonst gakonst moved this to Todo in Foundry Sep 19, 2022
@rkrasiuk rkrasiuk added C-forge Command: forge Cmd-forge-flatten Command: forge flatten labels Sep 19, 2022
@rkrasiuk rkrasiuk self-assigned this Sep 19, 2022
@adhusson
Copy link
Contributor

Also related to #2545 (maybe the same?).

@rkrasiuk
Copy link
Collaborator

rkrasiuk commented Oct 3, 2022

@chad-js sorry for delay on this. the issue is a little bit different than the above, however, the underlying problem is also non-trivial.
in your opinion, what would be the expected behavior if the same source unit is aliased differently across source files
i.e.

// file1.sol
import { IERC20 } from "src/interfaces/IERC20.sol";

// file2.sol
import { IERC20 as MyIERC20 } from "src/interfaces/IERC20.sol";

// file3.sol
import { IERC20 as CustomIERC20 } from "src/interfaces/IERC20.sol";

@mds1
Copy link
Collaborator

mds1 commented Oct 5, 2022

@rkrasiuk in your above example, can you just drop the renames and then everything is the same IERC20?

But if the IERC20's are from different file paths, it gets more complex. In that case I think we can include the renamed interfaces in the flattened file, such as:

  • interface IERC20 { /* snip */ } is left unchanged
  • interface MyERC20 { /*snip */} holds the code that was in it's imported IERC20 interface
  • interface CustomIERC20 { /*snip */} holds the code that was in that imported IERC20 interface

Perhaps I am misunderstanding the complications though?

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-flatten Command: forge flatten T-bug Type: bug
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

4 participants