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

Accessing constants in pure functions #6522

Closed
RenanSouza2 opened this issue Apr 15, 2019 · 3 comments
Closed

Accessing constants in pure functions #6522

RenanSouza2 opened this issue Apr 15, 2019 · 3 comments

Comments

@RenanSouza2
Copy link

Abstract

Make possible to access constants in pure functions

Motivation

Pure functions cannot access environment variables, but constants are decided in compile time.

Backwards Compatibility

If the function is pure bute call calls an old contract view function, being this view only due to a constant access, the new function needs to also be view

@chriseth
Copy link
Contributor

Can you give some example code, please?

@RenanSouza2
Copy link
Author

RenanSouza2 commented Apr 15, 2019

    contract SomeContract {
        uint256 constant public ID = 0;
    }

    contract Test {
        SomeContract public some;
        
        function setSome (address _some)
        external {
            some = SomeContract(_some);
        }
        
        function getID ()
        external view returns (uint256) {
            return some.ID();
        }
    }

Shouldn't the getID() be pure as the ID cannot be changed

@chriseth
Copy link
Contributor

This is a duplicate of #1290 - I actually thought that was already implemented.

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