Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

solc: handle conflicting <file>/<contract name> pairs properly #1487

Closed
mattsse opened this issue Jul 19, 2022 · 2 comments · Fixed by #1491
Closed

solc: handle conflicting <file>/<contract name> pairs properly #1487

mattsse opened this issue Jul 19, 2022 · 2 comments · Fixed by #1491

Comments

@mattsse
Copy link
Collaborator

mattsse commented Jul 19, 2022

as highlighted here foundry-rs/foundry#1488

when emitting duplicated file + contract name pairs we end up overwriting them.

This is a scenario I did not anticipate when implementing the output handler and a limitation of the current layout file/contract-name.sol

we handle multiple versions with a version suffix in the file name.

if there are multiple file+name pairs it's guaranteed that the file is in another folder, meaning parent(file) is always unique. so perhaps if there are conflicts, we add the parent(file)|project roo to the output path.

either has out/parent(file)/file/contract.sol

@gakonst
Copy link
Owner

gakonst commented Jul 20, 2022

I would have expected this to be an anti pattern..agree it's an edge case we hadn't considered.

I think we end up having to add directory nesting e.g. out/inner/a.json & out/a.json next to each other? But maybe we only "unflatten" the artifacts that are conflicting?

@onbjerg
Copy link
Collaborator

onbjerg commented Jul 20, 2022

Artifacts are in out/<filename>/<contract>.json, so if you have something like:

src/a/Token.sol
src/b/Token.sol

and both of them have a similar named contract (e.g. Token), then you'd have a conflict in the out directory, more specifically for this example, both would be trying to write to out/Token.sol/Token.json. Doesn't happen often I think, but does happen sometimes - I can imagine this is "worse" for us because dependencies might have contracts/file names similar to yours as well

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

Successfully merging a pull request may close this issue.

3 participants