Component
Forge
Have you ensured that all of these are up to date?
What version of Foundry are you on?
forge 0.2.0 (9ed1c37 2022-08-01T00:09:10.803586Z)
What command(s) is the bug in?
forge flatten
Operating System
macOS (Apple Silicon)
Describe the bug
Issue
When a flattened file contains a qualified import (of the form import path as Q), then:
Q is not stripped from accesses to definitions found in path. For instance, Q.structName does not become structName.
- Names that clash with other names defined in other imported files are not modified to be unique. For instance, if the struct
DataType is imported (with qualifier) from two files, compilation will fail.
Suggestion
forge flatten should strip all qualifiers, and rename definitions as needed (recursively).
Example:
// contract.sol
pragma solidity ^0.8.13;
import "./aux1.sol" as A;
import "./aux2.sol" as B;
contract C {
struct Data { A.DataType a; B.DataType b; }
}
// aux1.sol
struct DataType { string s; }
// aux2.sol
struct DataType { string s; }
forge flatten results in this (which fails to compile):
pragma solidity ^0.8.13;
struct DataType { string s; }
struct DataType { string s; }
contract C {
struct Data { A.DataType a; B.DataType b; }
}
when it should result in something like
pragma solidity ^0.8.13;
struct DataType1 { string s; }
struct DataType2 { string s; }
contract C {
struct Data { DataType1 a; DataType2 b; }
}
Note: this is kind of a followup to #1440.
Component
Forge
Have you ensured that all of these are up to date?
What version of Foundry are you on?
forge 0.2.0 (9ed1c37 2022-08-01T00:09:10.803586Z)
What command(s) is the bug in?
forge flatten
Operating System
macOS (Apple Silicon)
Describe the bug
Issue
When a flattened file contains a qualified import (of the form
import path as Q), then:Qis not stripped from accesses to definitions found inpath. For instance,Q.structNamedoes not becomestructName.DataTypeis imported (with qualifier) from two files, compilation will fail.Suggestion
forge flattenshould strip all qualifiers, and rename definitions as needed (recursively).Example:
forge flattenresults in this (which fails to compile):when it should result in something like
Note: this is kind of a followup to #1440.