From 4ae59acc098c2ede9a2dc44e741a28df49cc59d2 Mon Sep 17 00:00:00 2001 From: Daniel Kirchner Date: Fri, 10 Aug 2018 16:15:39 +0200 Subject: Consider mappings return values in control flow analysis. --- test/libsolidity/syntaxTests/controlFlow/mappingReturn/named_err.sol | 5 +++++ .../libsolidity/syntaxTests/controlFlow/mappingReturn/named_fine.sol | 5 +++++ .../syntaxTests/controlFlow/mappingReturn/unnamed_err.sol | 5 +++++ .../syntaxTests/controlFlow/mappingReturn/unnamed_fine.sol | 5 +++++ 4 files changed, 20 insertions(+) create mode 100644 test/libsolidity/syntaxTests/controlFlow/mappingReturn/named_err.sol create mode 100644 test/libsolidity/syntaxTests/controlFlow/mappingReturn/named_fine.sol create mode 100644 test/libsolidity/syntaxTests/controlFlow/mappingReturn/unnamed_err.sol create mode 100644 test/libsolidity/syntaxTests/controlFlow/mappingReturn/unnamed_fine.sol (limited to 'test/libsolidity') 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; } +} +// ---- -- cgit