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

Warn if built-in globals are shadowed #1249

Closed
codywatts opened this issue Oct 20, 2016 · 2 comments
Closed

Warn if built-in globals are shadowed #1249

codywatts opened this issue Oct 20, 2016 · 2 comments
Assignees

Comments

@codywatts
Copy link

"Built-in" functions such as sha3 and selfdestruct can be hidden by functions and events with the same name. This can alter the functionality of contracts in non-obvious ways.

Consider the following contract:

pragma solidity ^0.4.2;

contract FakingItsOwnDeath {
    function selfdestruct(address x) internal constant {}
}

contract SelfDestructive is FakingItsOwnDeath {
    function die() public {
        selfdestruct(address(0x0));
    }
}

At a glance, SelfDestructive.die appears to destroy the contract. But in fact, it's actually calling FakingItsOwnDeath.selfdestruct rather than the built-in version of selfdestruct and so the contract doesn't die.

It is also to possible to create functions/events called this and now.

(Tested using version 0.4.2+commit.af6afb04.mod.Emscripten.clang of the online Solidity compiler.)

@codywatts codywatts changed the title Functions and events can hide special variables and functions Local functions and events can hide "special" variables and functions Oct 20, 2016
@chriseth
Copy link
Contributor

This is all intended but should probably result in a warning if built-ins are overwritten, yes.

@chriseth chriseth changed the title Local functions and events can hide "special" variables and functions Warn if built-in globals are shadowed Oct 20, 2016
@axic axic self-assigned this Feb 2, 2017
@axic axic added in progress and removed accepted labels Feb 2, 2017
@chriseth
Copy link
Contributor

This is also very important for revert()

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

3 participants