-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Bug: forge flatten
does not account for as
keyword in imports
#1440
Comments
@rkrasiuk perhaps we're using the offset of the wrong identifier? |
@mattsse so i've fixed parsing aliases using solang and our regex fallback. now the only question is how do we want to proceed with fixing the aliases in the flattened file. both renaming import target to the alias and renaming the alias back to the original import name have the edge cases that break the flattened file. // FixedPointMath.sol
library FixedPointMath { }
// Calculator1.sol
import {FixedPointMath as Math} from "./FixedPointMath.sol";
Math.mul();
// Calculator2.sol
import {FixedPointMath} from "./FixedPointMath.sol";
FixedPointMath.mul(); // this is where it would break |
hmm, this not ideal but not really solvable until we have proper formatting. |
sgtm, just want to make sure that these edge cases are acknowledged. so, you suggest replacing the alias with the original import name, not the other way around, right? |
can we replace per node or only once we've flattened everything? the other way around would include renaming the I'd think replacing the more verbose lib name with the alias could be more accurate but I don't think we should rename the library. so, I'd say let's replace alias |
we can replace per node, the only caveat is identifying correctly the token to replace. we either regex it on flattening or traverse the solang result and store information about various tokens used inside every file |
I think regexing should be sufficient :) |
closed by gakonst/ethers-rs#1192 |
Component
Forge
Have you ensured that all of these are up to date?
What version of Foundry are you on?
latest
What command(s) is the bug in?
forge flatten
Operating System
macOS (M1)
Describe the bug
the
as
keyword, used to remap imports likeis ignored by
forge flatten
, which just indiscriminately pastesFixedPointMath
in and fails to rename/alias it toMath
this results in the output of
forge flatten
failing to compile because the compiler does not know whatMath
is ifFixedPointMath
is not alias'd/renamed, while the input could be a perfectly valid contract like aboveThe text was updated successfully, but these errors were encountered: