Skip to content

Support --ir-minimum flag for forge coverage #23

@hudsonhrh

Description

@hudsonhrh

Problem

The coverage job runs forge coverage which disables via_ir for accurate instrumentation. However, projects that use IR-only features (e.g., calldata[] calldata to storage copying) fail to compile without the IR pipeline:

Error (1834): Copying of type struct IExecutor.Call calldata[] calldata to storage
is not supported in legacy (only supported by the IR pipeline).

This results in an empty coverage report (0/0 for all metrics).

Proposed Solution

Add an optional coverage-ir-minimum boolean input (default false). When enabled, pass --ir-minimum to forge coverage, which enables viaIR with minimal optimization — enough for IR-dependent code while still producing accurate coverage.

coverage-ir-minimum:
  description: 'Pass --ir-minimum to forge coverage for projects requiring the IR pipeline'
  type: boolean
  default: false

Then in the coverage step:

if [[ "${{ inputs.coverage-ir-minimum }}" == "true" ]]; then
  forge coverage --ir-minimum 2>&1 | tee coverage-raw.txt
else
  forge coverage 2>&1 | tee coverage-raw.txt
fi

Context

Encountered in POP when enabling run-coverage: true. The forge coverage warning itself suggests this flag:

If you encounter "stack too deep" errors, consider using --ir-minimum which enables viaIR with minimum optimization resolving most of the errors

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions