-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10971 from ethereum/onlyWarnAboutVariables
Only warn about variables being shadowed in inline assembly.
- Loading branch information
Showing
18 changed files
with
123 additions
and
79 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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
13 changes: 13 additions & 0 deletions
13
test/libsolidity/semanticTests/inlineAssembly/shadowing_local_function_opcode.sol
This file contains 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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
contract C { | ||
function add(uint, uint) public pure returns (uint) { return 7; } | ||
function g() public pure returns (uint x, uint y) { | ||
x = add(1, 2); | ||
assembly { | ||
y := add(1, 2) | ||
} | ||
} | ||
} | ||
// ==== | ||
// compileViaYul: also | ||
// ---- | ||
// g() -> 7, 3 |
9 changes: 9 additions & 0 deletions
9
test/libsolidity/syntaxTests/inlineAssembly/create2_as_variable_post_istanbul.sol
This file contains 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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
contract c { | ||
function f() public { | ||
uint create2; create2; | ||
assembly { pop(create2(0, 0, 0, 0)) } | ||
} | ||
} | ||
// ==== | ||
// EVMVersion: >=constantinople | ||
// ---- |
11 changes: 11 additions & 0 deletions
11
test/libsolidity/syntaxTests/inlineAssembly/create2_as_variable_pre_istanbul.sol
This file contains 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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
contract c { | ||
function f() public { | ||
uint create2; create2; | ||
assembly { pop(create2(0, 0, 0, 0)) } | ||
} | ||
} | ||
// ==== | ||
// EVMVersion: =byzantium | ||
// ---- | ||
// TypeError 6166: (78-85): The "create2" instruction is only available for Constantinople-compatible VMs (you are currently compiling for "byzantium"). | ||
// TypeError 3950: (78-97): Expected expression to evaluate to one value, but got 0 values instead. |
9 changes: 9 additions & 0 deletions
9
test/libsolidity/syntaxTests/inlineAssembly/extcodehash_as_variable_post_constantinople.sol
This file contains 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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
contract c { | ||
function f() public view { | ||
uint extcodehash; | ||
extcodehash; | ||
assembly { pop(extcodehash(0)) } | ||
} | ||
} | ||
// ==== | ||
// EVMVersion: >=constantinople |
12 changes: 12 additions & 0 deletions
12
test/libsolidity/syntaxTests/inlineAssembly/extcodehash_as_variable_pre_constantinople.sol
This file contains 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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
contract c { | ||
function f() public view { | ||
uint extcodehash; | ||
extcodehash; | ||
assembly { pop(extcodehash(0)) } | ||
} | ||
} | ||
// ==== | ||
// EVMVersion: =byzantium | ||
// ---- | ||
// TypeError 7110: (93-104): The "extcodehash" instruction is only available for Constantinople-compatible VMs (you are currently compiling for "byzantium"). | ||
// TypeError 3950: (93-107): Expected expression to evaluate to one value, but got 0 values instead. |
11 changes: 11 additions & 0 deletions
11
...olidity/syntaxTests/inlineAssembly/returndatasize_as_variable_call_post_byzantium.sol.sol
This file contains 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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
contract C { | ||
function f() public pure { | ||
uint returndatasize; | ||
returndatasize; | ||
assembly { | ||
let x := returndatasize() | ||
} | ||
} | ||
} | ||
// ==== | ||
// EVMVersion: >=byzantium |
13 changes: 13 additions & 0 deletions
13
test/libsolidity/syntaxTests/inlineAssembly/returndatasize_as_variable_post_byzantium.sol
This file contains 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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
contract C { | ||
function f() public pure { | ||
uint returndatasize; | ||
returndatasize; | ||
assembly { | ||
returndatasize := 2 | ||
} | ||
} | ||
} | ||
// ==== | ||
// EVMVersion: >=byzantium | ||
// ---- | ||
// ParserError 6272: (143-145): Cannot assign to builtin function "returndatasize". |
6 changes: 6 additions & 0 deletions
6
test/libsolidity/syntaxTests/inlineAssembly/returndatasize_as_variable_pre_byzantium.sol
This file contains 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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
contract C { function f() public pure { uint returndatasize; returndatasize; assembly { pop(returndatasize()) }}} | ||
// ==== | ||
// EVMVersion: =homestead | ||
// ---- | ||
// TypeError 4778: (92-106): The "returndatasize" instruction is only available for Byzantium-compatible VMs (you are currently compiling for "homestead"). | ||
// TypeError 3950: (92-108): Expected expression to evaluate to one value, but got 0 values instead. |
13 changes: 13 additions & 0 deletions
13
...olidity/syntaxTests/inlineAssembly/returndatasize_as_variable_read_post_byzantium.sol.sol
This file contains 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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
contract C { | ||
function f() public pure { | ||
uint returndatasize; | ||
returndatasize; | ||
assembly { | ||
let x := returndatasize | ||
} | ||
} | ||
} | ||
// ==== | ||
// EVMVersion: >=byzantium | ||
// ---- | ||
// ParserError 7104: (137-151): Builtin function "returndatasize" must be called. |
8 changes: 8 additions & 0 deletions
8
test/libsolidity/syntaxTests/inlineAssembly/shadowing/global_function_by_opcode.sol
This file contains 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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
function mload() pure {} | ||
contract C { | ||
function g() public pure { | ||
assembly { | ||
} | ||
} | ||
} | ||
// ---- |
9 changes: 9 additions & 0 deletions
9
test/libsolidity/syntaxTests/inlineAssembly/shadowing/local_function_by_opcode.sol
This file contains 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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
contract C { | ||
function add(uint, uint) public pure returns (uint) { return 7; } | ||
function g() public pure returns (uint x, uint y) { | ||
x = add(1, 2); | ||
assembly { | ||
y := add(1, 2) | ||
} | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
test/libsolidity/syntaxTests/inlineAssembly/shadowing/state_variable_by_opcode.sol
This file contains 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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
contract C { | ||
uint mload; | ||
function g() public pure { | ||
assembly { | ||
} | ||
} | ||
} | ||
// ---- |
This file contains 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