foundry icon indicating copy to clipboard operation
foundry copied to clipboard

feat(fmt): support `transient` keyword

Open adhusson opened this issue 1 year ago • 2 comments

Component

Forge

Have you ensured that all of these are up to date?

  • [X] Foundry
  • [X] Foundryup

What version of Foundry are you on?

forge 0.2.0 (f79c53c 2024-10-10T00:25:05.432733000Z)

What command(s) is the bug in?

forge fmt

Operating System

macOS (Apple Silicon)

Describe the bug

When the new transient keyword is used, forge fmt fails. For instance if transient is added to the number state variable of the initial Counter contract:

Error:
Failed to parse Solidity code for src/Counter.sol. Leaving source unchanged.

Context:
- failed to parse file:
Error: ParserError
   ╭─[:5:30]
   │
 5 │     uint256 public transient number;
   │                              ───┬──
   │                                 ╰──── unrecognised token 'number', expected ";", "="
───╯

adhusson avatar Oct 10 '24 12:10 adhusson

Hi @adhusson thanks for flagging

For future reference: https://soliditylang.org/blog/2024/10/09/solidity-0.8.28-release-announcement/ this was introduced in 0.8.28

To fix this we'll need an update to Solang: https://crates.io/crates/solang-parser

See: https://github.com/hyperledger-solang/solang/issues/1670

zerosnacks avatar Oct 11 '24 10:10 zerosnacks

Update @adhusson: the Solang team is now aware and adding it should be straightforward, just looking for the time to add it

zerosnacks avatar Oct 17 '24 13:10 zerosnacks

cc @DaniPopes do we support the transient keyword in Solar?

zerosnacks avatar Nov 11 '24 15:11 zerosnacks

Yes, this will be fixed by the migration

DaniPopes avatar Nov 12 '24 03:11 DaniPopes

we got the same issue. waiting for the fix.

cirethic avatar Jan 08 '25 01:01 cirethic

FYI this is tracked here https://github.com/foundry-rs/foundry/issues/9317

DaniPopes avatar Jan 08 '25 01:01 DaniPopes

Hi! Any workaround in the meantime?

I'm using:

uint128 public transient value; // forgefmt: disable-line

based on https://github.com/foundry-rs/foundry/issues/3572 but it does not work (when it should?).

Right now, I'm unable to use both forgefmt in our project because we use transient, which is pretty annoying 😢

lemunozm avatar Feb 24 '25 11:02 lemunozm