Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Troubles with optional type decoding #54

Closed
medved239 opened this issue May 20, 2021 · 1 comment
Closed

Troubles with optional type decoding #54

medved239 opened this issue May 20, 2021 · 1 comment

Comments

@medved239
Copy link

I'm trying to compile the following program

pragma ton-solidity ^0.44.0;

contract Mem {
    constructor() public {
        tvm.accept();
    }

    function test() internal returns (optional(uint256)) {
        TvmSlice data = msg.data;
        return data.decode(optional(uint256));
    }
}

and getting compilation Error: Return argument type optional(optional(uint256)) is not implicitly convertible to expected type (type of first return variable) optional(uint256).
So the type checker for some reason thinks that expression data.decode(optional(uint256)) has type optional(optional(uint256)).

And when compiling this code

pragma ton-solidity ^0.44.0;

contract Mem {
    constructor() public {
        tvm.accept();
    }

    struct Struct {
        optional(uint256) value;
    }

    function test() internal returns (Struct) {
        TvmSlice data = msg.data;
        return data.decode(Struct);
    }
}

I get "Unsupported parameter type for decoding: optional(uint256)". So optional type seems to be TvmBuilder.store'able, but not TvmSlice.decode'able, and that is pretty not convenient.

I hope you will support decoding optional types in a next release.

@IgorKoval
Copy link
Collaborator

Thank you! We will fix this in next release!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants