diff options
author | Daniel Kirchner <daniel@ekpyron.org> | 2018-08-10 22:15:39 +0800 |
---|---|---|
committer | Daniel Kirchner <daniel@ekpyron.org> | 2018-08-13 22:33:37 +0800 |
commit | 4ae59acc098c2ede9a2dc44e741a28df49cc59d2 (patch) | |
tree | 74948179e523a1b1697cc3844b80e9713db6b722 /test | |
parent | a9f31da41146221c674356d5678030616110d471 (diff) | |
download | dexon-solidity-4ae59acc098c2ede9a2dc44e741a28df49cc59d2.tar dexon-solidity-4ae59acc098c2ede9a2dc44e741a28df49cc59d2.tar.gz dexon-solidity-4ae59acc098c2ede9a2dc44e741a28df49cc59d2.tar.bz2 dexon-solidity-4ae59acc098c2ede9a2dc44e741a28df49cc59d2.tar.lz dexon-solidity-4ae59acc098c2ede9a2dc44e741a28df49cc59d2.tar.xz dexon-solidity-4ae59acc098c2ede9a2dc44e741a28df49cc59d2.tar.zst dexon-solidity-4ae59acc098c2ede9a2dc44e741a28df49cc59d2.zip |
Consider mappings return values in control flow analysis.
Diffstat (limited to 'test')
4 files changed, 20 insertions, 0 deletions
diff --git a/test/libsolidity/syntaxTests/controlFlow/mappingReturn/named_err.sol b/test/libsolidity/syntaxTests/controlFlow/mappingReturn/named_err.sol new file mode 100644 index 00000000..35420b6d --- /dev/null +++ b/test/libsolidity/syntaxTests/controlFlow/mappingReturn/named_err.sol @@ -0,0 +1,5 @@ +contract C { + function f() internal pure returns (mapping(uint=>uint) storage r) { } +} +// ---- +// TypeError: (53-82): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error. diff --git a/test/libsolidity/syntaxTests/controlFlow/mappingReturn/named_fine.sol b/test/libsolidity/syntaxTests/controlFlow/mappingReturn/named_fine.sol new file mode 100644 index 00000000..4146192f --- /dev/null +++ b/test/libsolidity/syntaxTests/controlFlow/mappingReturn/named_fine.sol @@ -0,0 +1,5 @@ +contract C { + mapping(uint=>uint) m; + function f() internal view returns (mapping(uint=>uint) storage r) { r = m; } +} +// ---- diff --git a/test/libsolidity/syntaxTests/controlFlow/mappingReturn/unnamed_err.sol b/test/libsolidity/syntaxTests/controlFlow/mappingReturn/unnamed_err.sol new file mode 100644 index 00000000..7e8c4501 --- /dev/null +++ b/test/libsolidity/syntaxTests/controlFlow/mappingReturn/unnamed_err.sol @@ -0,0 +1,5 @@ +contract C { + function f() internal pure returns (mapping(uint=>uint) storage) {} +} +// ---- +// TypeError: (53-72): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error. diff --git a/test/libsolidity/syntaxTests/controlFlow/mappingReturn/unnamed_fine.sol b/test/libsolidity/syntaxTests/controlFlow/mappingReturn/unnamed_fine.sol new file mode 100644 index 00000000..9c5e3149 --- /dev/null +++ b/test/libsolidity/syntaxTests/controlFlow/mappingReturn/unnamed_fine.sol @@ -0,0 +1,5 @@ +contract C { + mapping(uint=>uint) m; + function f() internal view returns (mapping(uint=>uint) storage) { return m; } +} +// ---- |