runtimeverification / runtimeverification/kontrol

`Array length bounds missing` error when constructor takes a struct that includes an array of structs

Open
#974 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Python
Stars
122
Forks
16
PR merge metrics
No merged PRs in 30d

Description

If the project includes a contract where the constructor takes a struct that itself contains an array of structs, kontrol build fails with the error:

ValueError: Array length bounds missing for <struct member>

This happens despite the fact that when array length bounds are not specified, they should default to 1, and it happens even if the bounds are specified using an annotation such as

/// @custom:kontrol-array-length-equals <struct member>: 10,`

This issue can be reproduced with the following minimal example:

pragma solidity ^0.8.17;

struct DeploymentParameters {
    Parameters[] parameters;
}

struct Parameters {
    uint256 value;
}

contract ArrayStructContract {
    constructor(DeploymentParameters memory) {
        // Do something
    }
}

Note that this only happens with constructors. If the constructor above is replaced with a function, kontrol build works. It also works if the Parameters[] array is replaced with a non-struct array such as uint256[].

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failure with the minimal Solidity example using kontrol build, then compare it with the function and uint256[] variants described in the issue. Trace the constructor path and array-length annotation/default handling; done means the struct-containing array constructor builds successfully with omitted bounds and with the shown annotation, while the existing working cases remain working.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, solidity
Domain
build-system, compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.