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

Friendlier messages when implicit constructor cannot be created #137

Open
hajduakos opened this issue Mar 9, 2020 · 2 comments
Open

Friendlier messages when implicit constructor cannot be created #137

hajduakos opened this issue Mar 9, 2020 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@hajduakos
Copy link
Member

If there is an unsupported feature in a function, we give a quite user friendly message and skip that function. However, implicit constructors are generated separately and for them this is not done, but rather some confusing errors are printed.

For the following contracts

pragma solidity >=0.5.0;

contract Base {
    constructor() public {
        assembly { /* ... */ }
    }
}

contract Derived is Base { }

we get the output

Error while running compiler, details:
Warning: This is a pre-release compiler version, please do not use it in production.

======= Converting to Boogie IVL =======

======= Impl.sol =======
Impl.sol:5:9: solc-verify error: Inline assembly is not supported
        assembly { /* ... */ }
        ^--------------------^
Impl.sol:4:5: solc-verify warning: Errors while translating function body, will be skipped
    constructor() public {
    ^ (Relevant source part starts here and spans across multiple lines).
Impl.sol:5:9: solc-verify error: Inline assembly is not supported
        assembly { /* ... */ }
        ^--------------------^

The first error and warning corresponds to skipping the constructor of Base. However there is an extra error afterwards that corresponds to inlining the constructor of Base when creating the implicit constructor of Derived, but this cannot be seen in the output. This also makes the whole translation and verification fail, instead of printing the skipped functions in a nice way. The workaround should be simple, we just have to include the error reporter swapping code from functions into implicit constructors as well.

@hajduakos hajduakos added the enhancement New feature or request label Mar 9, 2020
@hajduakos
Copy link
Member Author

If we add the constructor explicitly, it works:

pragma solidity >=0.5.0;

contract Base {
    constructor() public {
        assembly { /* ... */ }
    }
}

contract Derived is Base {
    constructor() public {}
}

gives

Base::[constructor]: SKIPPED
Derived::[constructor]: SKIPPED
Use --show-warnings to see 2 warnings.
Some functions were skipped. Use --show-warnings to see details.
No errors found.

Output should be similar if the constructor is implicit.

@hajduakos
Copy link
Member Author

Fixed in 4beece6

@hajduakos hajduakos self-assigned this Mar 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant