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

compile time constant variable declaration should allow use of pure functions #9292

Closed
thegostep opened this issue Jul 2, 2020 · 1 comment

Comments

@thegostep
Copy link

Description

compile time constant variable declaration should allow use of pure functions

Environment

  • Compiler version: 0.6

Steps to Reproduce

// current
uint256 public constant ATTRIBUTE_ID = uint256(keccak256(bytes("attribute")));

// expected
uint256 public constant ATTRIBUTE_ID = stringToUint("attribute");

function stringToUint(string memory attribute) public pure returns (uint256 attributeID) {
	return uint256(keccak256(bytes(attribute)));
}
@chriseth
Copy link
Contributor

chriseth commented Jul 2, 2020

Duplicate of #3122
The reason we did not implement this yet is mainly because the keyword pure does not really mean the same thing as "compile-time constant" - it just means "does not read blockchain state".

@chriseth chriseth closed this as completed Jul 2, 2020
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