Open 0xalpharush opened 8 months ago
@klkvr Related to https://github.com/foundry-rs/foundry/issues/5041 where we'd want similar functionality to only get ABIs without compiling, so we know which contracts to compile
This is not strictly blocked by https://github.com/ethereum/solidity/issues/15043 as additional stages would be trivial to add but it may be premature considering the original use case needs a semantic stage.
@klkvr Is there a way to not request bin
and only request ast
with Foundry. I think forge build --ast
(not sure why this wasn't just added to --extra-output
) still requests the bytecode. I would prefer the AST in the hardhat style artifact just with everything else missing (key is there but value is empty) because the foundry native artifact format has several latent bugs e.g. https://github.com/gakonst/ethers-rs/issues/1995
I wonder if adding a flag for bytecode (and defaulting it on) would help with this? then you could do something like forge build --ast --bytecode=false
to get just the AST?
We'd love to have this in https://github.com/latticexyz/mud so we replace our dependency on https://github.com/solidity-parser/parser (which has subpar syntax error output)
I'm now thinking what I'd prefer is actually just a forge ast path/to/file.sol
that emits the AST JSON to stdout, then can pipe to other tools like jq, etc.
Component
Forge
Describe the feature you would like
UPDATE see https://github.com/foundry-rs/foundry/issues/7212#issuecomment-2075291224
I would like the forge build command to expose this, so one can pass
--stop-after parsing
solc and only get the AST without compiling to bytecodeAs a potential optimization, foundry could look if the solidity files' content is unchanged and reuse the AST on disk for compilation by giving them to solc when
forge build --stop-after parsing && forge build/test
is run.Additional context
from https://github.com/ethereum/solidity/blob/develop/docs/using-the-compiler.rst#compiler-input-and-output-json-description: