Skip to content

Internal calls reject fixed-size byte struct fields as arguments #67

@michaelsutton

Description

@michaelsutton

User-defined internal calls currently reject fixed-size byte struct field expressions as arguments, even though the same value is accepted once first bound to a local.

This fails:

contract Calls(byte[64] init_data) {
    byte[64] data = init_data;

    function f(byte[64] b) : (int) {
        return(b.length);
    }

    function step(State prev_state) {
        (int len) = f(prev_state.data); // <- fails here
        require(len == 64);
    }

    entrypoint function main() {
        step({ data: data });
    }
}

with:

function argument 'b' expects byte[64]

This works:

contract Calls(byte[64] init_data) {
    byte[64] data = init_data;

    function f(byte[64] b) : (int) {
        return(b.length);
    }

    function step(State prev_state) {
        byte[64] local_data = prev_state.data;
        (int len) = f(local_data);
        require(len == 64);
    }

    entrypoint function main() {
        step({ data: data });
    }
}

As shown in the second example, the current workaround is to first bind the field to a local.

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