Skip to content

Coverage: could not find anchor error thrown if function is empty  #2471

Closed
@varunsrin

Description

@varunsrin

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 (64fe4ac 2022-07-25T00:20:31.96755Z)

What command(s) is the bug in?

forge coverage

Operating System

macOS (Apple Silicon)

Describe the bug

forge coverage fails with an error if it encounters an empty function call in a contract. Should it simply show coverage as 0.00% instead and succeed?

It isn't a major issue, since once you see the error and inspect the code, it's fairly obvious what's causing it and you probably shouldn't have empty functions anyway.

You can test it by running it against this contract. (cc @onbjerg )

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

contract ForgeCovErrorRepro {
    function doNothing() public {}
}

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions