Skip to content

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

@zaqk

Description

@zaqk

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

Completed

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions