Skip to content

Introduce view state-mutability (keep constant as alias)#2762

Merged
axic merged 4 commits intodevelopfrom
statemutability-view
Aug 22, 2017
Merged

Introduce view state-mutability (keep constant as alias)#2762
axic merged 4 commits intodevelopfrom
statemutability-view

Conversation

@axic
Copy link
Contributor

@axic axic commented Aug 16, 2017

Part of #992.

@axic axic changed the title Introduce view state-mutability (keep constant as alias) [WIP] Introduce view state-mutability (keep constant as alias) Aug 21, 2017
@axic axic force-pushed the statemutability-view branch 3 times, most recently from 2dcabe5 to 8b2cc41 Compare August 21, 2017 14:46
method["name"] = it.second->declaration().name();
method["constant"] = it.second->isConstant();
// FIXME: constant should be removed at the next breaking release
method["constant"] = it.second->isView();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Basically it is only used here and in one test. Probably worth replacing with a direct check to statemutability.

@axic
Copy link
Contributor Author

axic commented Aug 21, 2017

Need to add tests for view.

@axic axic force-pushed the statemutability-view branch from 8b2cc41 to 473d3b4 Compare August 21, 2017 22:42
@axic axic changed the title [WIP] Introduce view state-mutability (keep constant as alias) Introduce view state-mutability (keep constant as alias) Aug 21, 2017
@axic axic force-pushed the statemutability-view branch 3 times, most recently from 078286d to bb0ad04 Compare August 22, 2017 11:31
@axic
Copy link
Contributor Author

axic commented Aug 22, 2017

@chriseth this should be ready now

auto returnParams = function->returnParameterTypes();
BOOST_CHECK_EQUAL(returnParams.at(0)->canonicalName(false), "uint256");
BOOST_CHECK(function->isConstant());
BOOST_CHECK(function->stateMutability() == StateMutability::View);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These here require View (and cannot be substituted by Pure) because they ensure getters are view.

@axic axic force-pushed the statemutability-view branch from 5daf7ff to 1d093c6 Compare August 22, 2017 11:44
**************

Functions can be declared constant in which case they promise not to modify the state.
Functions can be declared view in which case they promise not to modify the state.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In quotes?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated all.

@axic axic force-pushed the statemutability-view branch from 1d093c6 to b1cdf81 Compare August 22, 2017 17:26
@axic axic merged commit 0ffc5db into develop Aug 22, 2017
@axic axic removed the in progress label Aug 22, 2017
@axic axic deleted the statemutability-view branch August 22, 2017 18:09
pemulis added a commit to pemulis/cryptokittybox that referenced this pull request Mar 10, 2018
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

Successfully merging this pull request may close these issues.

2 participants