Skip to content

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

@lucasmt

Description

@lucasmt

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[].

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions