-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Deprecate the var keyword in SyntaxChecker #3425
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1844,7 +1844,10 @@ BOOST_AUTO_TEST_CASE(warn_var_from_zero) | |
| } | ||
| } | ||
| )"; | ||
| CHECK_WARNING(sourceCode, "uint8, which can hold values between 0 and 255"); | ||
| CHECK_WARNING_ALLOW_MULTI(sourceCode, (std::vector<std::string>{ | ||
| "uint8, which can hold values between 0 and 255", | ||
| "Use of the \"var\" keyword is deprecated." | ||
| })); | ||
| sourceCode = R"( | ||
| contract test { | ||
| function f() pure public { | ||
|
|
@@ -1853,7 +1856,10 @@ BOOST_AUTO_TEST_CASE(warn_var_from_zero) | |
| } | ||
| } | ||
| )"; | ||
| CHECK_WARNING(sourceCode, "uint256, which can hold values between 0 and 115792089237316195423570985008687907853269984665640564039457584007913129639935"); | ||
| CHECK_WARNING_ALLOW_MULTI(sourceCode, (std::vector<std::string>{ | ||
| "uint256, which can hold values between 0 and 115792089237316195423570985008687907853269984665640564039457584007913129639935", | ||
| "Use of the \"var\" keyword is deprecated." | ||
| })); | ||
| sourceCode = R"( | ||
| contract test { | ||
| function f() pure public { | ||
|
|
@@ -1862,15 +1868,21 @@ BOOST_AUTO_TEST_CASE(warn_var_from_zero) | |
| } | ||
| } | ||
| )"; | ||
| CHECK_WARNING(sourceCode, "int8, which can hold values between -128 and 127"); | ||
| CHECK_WARNING_ALLOW_MULTI(sourceCode, (std::vector<std::string>{ | ||
| "int8, which can hold values between -128 and 127", | ||
| "Use of the \"var\" keyword is deprecated." | ||
| })); | ||
| sourceCode = R"( | ||
| contract test { | ||
| function f() pure public { | ||
| for (var i = 0; i < msg.data.length; i++) { } | ||
| } | ||
| } | ||
| )"; | ||
| CHECK_WARNING(sourceCode, "uint8, which can hold"); | ||
| CHECK_WARNING_ALLOW_MULTI(sourceCode, (std::vector<std::string>{ | ||
| "uint8, which can hold", | ||
| "Use of the \"var\" keyword is deprecated." | ||
| })); | ||
| } | ||
|
|
||
| BOOST_AUTO_TEST_CASE(enum_member_access) | ||
|
|
@@ -4887,8 +4899,7 @@ BOOST_AUTO_TEST_CASE(warn_about_callcode) | |
| char const* text = R"( | ||
| contract test { | ||
| function f() pure public { | ||
| var x = address(0x12).callcode; | ||
| x; | ||
| address(0x12).callcode; | ||
| } | ||
| } | ||
| )"; | ||
|
|
@@ -4897,8 +4908,7 @@ BOOST_AUTO_TEST_CASE(warn_about_callcode) | |
| pragma experimental "v0.5.0"; | ||
| contract test { | ||
| function f() pure public { | ||
| var x = address(0x12).callcode; | ||
| x; | ||
| address(0x12).callcode; | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here |
||
| } | ||
| )"; | ||
|
|
@@ -6918,7 +6928,7 @@ BOOST_AUTO_TEST_CASE(function_types_sig) | |
| } | ||
| } | ||
| )"; | ||
| CHECK_SUCCESS_NO_WARNINGS(text); | ||
| CHECK_WARNING(text, "Use of the \"var\" keyword is deprecated."); | ||
| text = R"( | ||
| contract C { | ||
| function h() pure external { | ||
|
|
@@ -6941,7 +6951,7 @@ BOOST_AUTO_TEST_CASE(function_types_sig) | |
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you don't modify the test by adding a type for |
||
| } | ||
| )"; | ||
| CHECK_SUCCESS_NO_WARNINGS(text); | ||
| CHECK_WARNING(text, "Use of the \"var\" keyword is deprecated."); | ||
| } | ||
|
|
||
| BOOST_AUTO_TEST_CASE(using_this_in_constructor) | ||
|
|
@@ -7349,7 +7359,7 @@ BOOST_AUTO_TEST_CASE(warn_about_sha3) | |
| char const* text = R"( | ||
| contract test { | ||
| function f() pure public { | ||
| var x = sha3(uint8(1)); | ||
| bytes32 x = sha3(uint8(1)); | ||
| x; | ||
| } | ||
| } | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be checked that this error message is present until we disallow var completely.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you clarify?
CHECK_WARNING_ALLOW_MULTIseems to only allow the first warning to be checked, so ifvaris used in this test it will cause the first warning and it will not be possible to check for the size warning. Is there a way to check both?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I fear someone has to extend the macro...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could look into this within the next week or so. Do you want to file it as a separate issue?