aboutsummaryrefslogtreecommitdiffstats
path: root/test/libsolidity/syntaxTests
diff options
context:
space:
mode:
authorAlex Beregszaszi <alex@rtfs.hu>2018-04-21 00:32:50 +0800
committerGitHub <noreply@github.com>2018-04-21 00:32:50 +0800
commit72b0412ef68f332c9dcdc66b554aabc3fb69ba59 (patch)
tree48c0402a2b019d8fd3670539ffa10f93188b8468 /test/libsolidity/syntaxTests
parent676732776eaf087a17b79bc97213c84746dabd09 (diff)
parent65345162b4217c7d3f9035ee8d2f4c3fa2ecb72a (diff)
downloaddexon-solidity-72b0412ef68f332c9dcdc66b554aabc3fb69ba59.tar.gz
dexon-solidity-72b0412ef68f332c9dcdc66b554aabc3fb69ba59.tar.zst
dexon-solidity-72b0412ef68f332c9dcdc66b554aabc3fb69ba59.zip
Merge pull request #3956 from ethereum/tight-pack-hash
Make literals an error for tight packing (experimental 0.5.0)
Diffstat (limited to 'test/libsolidity/syntaxTests')
-rw-r--r--test/libsolidity/syntaxTests/tight_packing_literals_050.sol26
-rw-r--r--test/libsolidity/syntaxTests/tight_packing_literals_fine.sol17
2 files changed, 40 insertions, 3 deletions
diff --git a/test/libsolidity/syntaxTests/tight_packing_literals_050.sol b/test/libsolidity/syntaxTests/tight_packing_literals_050.sol
new file mode 100644
index 00000000..617af543
--- /dev/null
+++ b/test/libsolidity/syntaxTests/tight_packing_literals_050.sol
@@ -0,0 +1,26 @@
+pragma experimental "v0.5.0";
+contract C {
+ function f() pure public returns (bytes32) {
+ return keccak256(1);
+ }
+ function g() pure public returns (bytes32) {
+ return sha3(1);
+ }
+ function h() pure public returns (bytes32) {
+ return sha256(1);
+ }
+ function j() pure public returns (bytes32) {
+ return ripemd160(1);
+ }
+ function k() pure public returns (bytes) {
+ return abi.encodePacked(1);
+ }
+}
+
+// ----
+// TypeError: (117-118): Cannot perform packed encoding for a literal. Please convert it to an explicit type first.
+// Warning: (191-198): "sha3" has been deprecated in favour of "keccak256"
+// TypeError: (196-197): Cannot perform packed encoding for a literal. Please convert it to an explicit type first.
+// TypeError: (277-278): Cannot perform packed encoding for a literal. Please convert it to an explicit type first.
+// TypeError: (361-362): Cannot perform packed encoding for a literal. Please convert it to an explicit type first.
+// TypeError: (450-451): Cannot perform packed encoding for a literal. Please convert it to an explicit type first.
diff --git a/test/libsolidity/syntaxTests/tight_packing_literals_fine.sol b/test/libsolidity/syntaxTests/tight_packing_literals_fine.sol
index 46407f71..81e69eb4 100644
--- a/test/libsolidity/syntaxTests/tight_packing_literals_fine.sol
+++ b/test/libsolidity/syntaxTests/tight_packing_literals_fine.sol
@@ -2,10 +2,21 @@ contract C {
function f() pure public returns (bytes32) {
return keccak256(uint8(1));
}
- function g() pure public returns (bytes) {
- return abi.encode(1);
+ function g() pure public returns (bytes32) {
+ return sha3(uint8(1));
+ }
+ function h() pure public returns (bytes32) {
+ return sha256(uint8(1));
+ }
+ function j() pure public returns (bytes32) {
+ return ripemd160(uint8(1));
}
- function h() pure public returns (bytes) {
+ function k() pure public returns (bytes) {
return abi.encodePacked(uint8(1));
}
+ function l() pure public returns (bytes) {
+ return abi.encode(1);
+ }
}
+// ----
+// Warning: (168-182): "sha3" has been deprecated in favour of "keccak256"