Skip to content

bug: udvts of shielded types can be returned from public/external functions #117

@samlaf

Description

@samlaf

In #114 we are making any type that contains a shielded type impossible to be returned from a public/external function. The goal here is to prevent silly mistakes and force devs to type-cast to fully public types when returning values.

However, I have noticed that our solidity fork does not consider user defined value types (udvts). For example this test fails:

// test/libsolidity/syntaxTests/visibility/shielded_udvt_return.sol
type mysbool is sbool;

contract Deployer {
    mysbool private storedBoolean;

    // SHOULD RETURN AN ERROR, BUT DOESN'T
    function getStoredBooleanFailExternal() external returns (mysbool) {
        return storedBoolean;
    }

    // SHOULD RETURN AN ERROR, BUT DOESN'T
    function getStoredBooleanFailPublic() public returns (mysbool) {
        return storedBoolean;
    }
}
// ----
// DeclarationError 7492: (217-222): Shielded objects cannot be returned from public or external functions. Use internal or private functions or cast to an unshielded type.
// DeclarationError 7492: (321-326): Shielded objects cannot be returned from public or external functions. Use internal or private functions or cast to an unshielded type.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions