Skip to content
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(compiler): the ether keyword breaks forge scripts when ran as forge script Foo #9433

Closed
2 tasks done
zaqk opened this issue Nov 29, 2024 · 5 comments · Fixed by #9455
Closed
2 tasks done

bug(compiler): the ether keyword breaks forge scripts when ran as forge script Foo #9433

zaqk opened this issue Nov 29, 2024 · 5 comments · Fixed by #9455
Assignees
Labels
A-compiler Area: compiler P-low Priority: low T-bug Type: bug
Milestone

Comments

@zaqk
Copy link

zaqk commented Nov 29, 2024

Component

Forge

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

  • Foundry
  • Foundryup

What version of Foundry are you on?

forge 0.2.0 (27cabbd 2024-11-29T00:28:06.641192000Z)

What command(s) is the bug in?

forge script

Operating System

macOS (Apple Silicon)

Describe the bug

it seems the use of the ether keyword anywhere in a forge script contract will cause break forge script.

My code:

// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.10;

import {Script} from "forge-std/Script.sol";

contract POC is Script {

    function run() external {
        uint256 a = .1 ether;
    }

}

The error:

▶ forge script POC
Error: No contract found with the name `POC`

a workaround is to just not use the keyword.

Workaround code:

// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.10;

import {Script} from "forge-std/Script.sol";

contract POC is Script {

    function run() external {
        uint256 a = 1e17;
    }

}

console output

▶ forge script POC
[⠊] Compiling...
No files changed, compilation skipped
Script ran successfully.
Gas used: 21161

@zaqk zaqk added T-bug Type: bug T-needs-triage Type: this issue needs to be labelled labels Nov 29, 2024
@github-project-automation github-project-automation bot moved this to Todo in Foundry Nov 29, 2024
@zerosnacks
Copy link
Member

zerosnacks commented Nov 29, 2024

Hi @zaqk thanks for the bug report

I'm able to reproduce it with the given setup and it appears to be a regression

@zerosnacks zerosnacks added A-compiler Area: compiler and removed T-needs-triage Type: this issue needs to be labelled labels Nov 29, 2024
@zerosnacks zerosnacks changed the title the ether keyword breaks forge scripts bug(compiler): the ether keyword breaks forge scripts Nov 29, 2024
@zerosnacks
Copy link
Member

zerosnacks commented Nov 29, 2024

Update: appears to be related to a change introduced in #9346 or #8668 + https://github.com/foundry-rs/compilers

Fails: git checkout c13d42e850da353c0856a8b0d4123e13cc40045d
Works: git checkout e649e62f125244a3ef116be25dfdc81a2afbaf2a

cc @klkvr

@zerosnacks zerosnacks added this to the v1.0.0 milestone Nov 29, 2024
@zerosnacks zerosnacks added the P-normal Priority: normal label Nov 29, 2024
@zerosnacks
Copy link
Member

zerosnacks commented Nov 29, 2024

It is not exactly clear why the ether keyword (no inlining / dead code elimination?) is relevant here but running it as forge script script/POC.s.sol this works as expected

Re-rating to p-low given that there is a workaround and only occurs in some edge cases

@zerosnacks zerosnacks changed the title bug(compiler): the ether keyword breaks forge scripts bug(compiler): the ether keyword breaks forge scripts when ran as forge script Foo Nov 29, 2024
@zaqk
Copy link
Author

zaqk commented Nov 29, 2024

also worth noting i didnt run into the issue if i used 1 ether.

@zerosnacks zerosnacks added P-low Priority: low and removed P-normal Priority: normal labels Nov 29, 2024
klkvr pushed a commit to foundry-rs/compilers that referenced this issue Nov 29, 2024
Fixes after bump foundry-rs/foundry#9433
@DaniPopes DaniPopes self-assigned this Nov 29, 2024
@DaniPopes DaniPopes moved this from Todo to Ready For Review in Foundry Nov 30, 2024
@DaniPopes DaniPopes moved this from Ready For Review to In Progress in Foundry Nov 30, 2024
@DaniPopes DaniPopes moved this from In Progress to Done in Foundry Nov 30, 2024
@DaniPopes DaniPopes moved this from Done to Completed in Foundry Dec 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-compiler Area: compiler P-low Priority: low T-bug Type: bug
Projects
Status: Completed
Development

Successfully merging a pull request may close this issue.

3 participants