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

All code examples should use the latest released version of Solidity #3379

Closed
3 of 93 tasks
fulldecent opened this issue Jan 5, 2018 · 16 comments
Closed
3 of 93 tasks

Comments

@fulldecent
Copy link
Contributor

fulldecent commented Jan 5, 2018

As per http://solidity.readthedocs.io/en/develop/installing-solidity.html?highlight=latest we see:

We recommend using the latest release.

The latest version is 0.4.19 as per https://github.com/ethereum/solidity/releases

The Solidity code examples in the documentation, therefore, should also use version 0.4.19.


Following are the examples to update, found with git grep --line-number 'pragma solidity'.

Work plan:

  • Run the existing code under 0.4.19
  • Fix any warnings
  • Fix the code and the update the compiler version


Follow on work:

@fulldecent
Copy link
Contributor Author

It will be helpful if someone with authority can say "all code with 0.4.16 can compile without warnings on 0.4.19 with no changes necessary".

@axic
Copy link
Member

axic commented Jan 5, 2018

Please note those are the minimum versions required by each example. Since it uses semver, ^0.4.0 means it will also compile with 0.4.19.

Every change is backwards compatible, fixing warnings emitted by 0.4.19 will still results in a compilable code on 0.4.0.

@fulldecent
Copy link
Contributor Author

Counter example:

This compiles in 0.4.19 but not in 0.4.0:

pragma solidity ^0.4.19;

contract A {
    function a() public pure;
}

@axic
Copy link
Member

axic commented Jan 24, 2018

I do not exactly follow what counter example is this?

@fulldecent
Copy link
Contributor Author

You stated "fixing warnings emitted by 0.4.19 will still results in a compilable code on 0.4.0."

This counter example shows a contract where warnings are fixed in 0.4.19 but where the code does not compile in 0.4.0.

@axic
Copy link
Member

axic commented Jan 24, 2018

That is a response to your original issue listing this task:

Fix any warnings

What I've said is that fixing warnings in the code to make the 0.4.19 compiler silent will still result in code which can be compiled with >=0.4.0 (if the given pragma is ^0.4.0).

If there is a given code piece which already requires a higher version, that is for a reason, which is it uses a feature introduced in that given version.

You have also mentioned that all pragmas should be updated to require the latest version:

The Solidity code examples in the documentation, therefore, should also use version 0.4.19.

I do not agree with this, all examples should use the minimum version they require.

@fulldecent
Copy link
Contributor Author

Here is a screenshot where the 0.4.19 compiler using 0.4.0 pragma does recommend a change that is incompatible with 0.4.0.

screen shot 2018-01-23 at 9 11 06 pm

@fulldecent
Copy link
Contributor Author

When developing documentation I subscribe to the best practices:

  • Warnings are errors
  • If a code example causes an error with the latest released compiler then the code example should be fixed

Currently "Improving the documentation" is the first item listed for contributors to help with. If a different set of best practices apply for code snippets in the Solidity project, then it would be helpful to spell that out in http://solidity.readthedocs.io/en/latest/contributing.html so contributors can make more useful contributions.

@axic
Copy link
Member

axic commented Jan 24, 2018

I've never opposed adding state mutability modifiers (pure, view) to examples (I think somebody started doing that in a PR a while back). If we do that, of course the version requirement must bump to where it was introduced.

@fulldecent
Copy link
Contributor Author

Cool. So basically most things before 0.4.16 are at least in scope for an update to 0.4.16 for mutability guarantees. If I can find an important feature past 0.4.16 then that's a reason to upgrade further. But otherwise, maintain the oldest supported prama for any given code.

Here's a first step: #3431

chriseth added a commit that referenced this issue Jan 29, 2018
Add mutability declaration to example, for #3379
chriseth added a commit that referenced this issue Jan 29, 2018
Fix new Solidity warnings, for #3379
@leonardoalt
Copy link
Member

Currently (v0.5.0) almost all examples in the documentation have the form pragma solidity >=0.4.0 <0.6.0 which is correct. There are 3 "wrong" ones that should be checked.

@ChrisChinchilla
Copy link
Contributor

@leonardoalt after a quick search I can't see any more now, unless you can point me to those remaining 3 (possibly 2, as one was fixed in af3e6db)

@leonardoalt
Copy link
Member

The different ones that I found:

050-breaking-changes.rst:   pragma solidity ^0.4.25;
050-breaking-changes.rst:   pragma solidity ^0.4.25;
layout-of-source-files.rst:  pragma solidity ^0.4.0;

@ChrisChinchilla
Copy link
Contributor

@leonardoalt I think all of these are intentional if you read the context around them. As far as I can tell, this issue is now resolved.

@chriseth
Copy link
Contributor

The one in layout could be updated, but does not have to.

Furthermore, shouldn't we change all 0.4.99 to 0.5.0?

@ChrisChinchilla
Copy link
Contributor

@chriseth I guess we should. I shall update and hope that all tests still pass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants