Add syntax tests for inline array with invalid UTF8 sequences

This commit is contained in:
wechman 2022-06-06 08:45:54 +02:00
parent 0f55a4d671
commit ce09750656
3 changed files with 20 additions and 7 deletions

View File

@ -1,7 +0,0 @@
contract C {
function f1() external pure returns (string[1] memory rdatas) {
rdatas = [hex'c0a80101'];
}
}
// ----
// TypeError 7407: (110-125): Type inline_array(literal_string hex"c0a80101") is not implicitly convertible to expected type string memory[1] memory. Invalid conversion from literal_string hex"c0a80101" to string memory. Contains invalid UTF-8 sequence at position 4.

View File

@ -0,0 +1,9 @@
contract C {
function f() external pure {
string[2] memory a1 = [string(bytes(hex'74000001')), string(bytes(hex'c0a80101'))];
bytes[2] memory a2 = [bytes(hex'74000001'), bytes(hex'c0a80101')];
}
}
// ----
// Warning 2072: (54-73): Unused local variable.
// Warning 2072: (146-164): Unused local variable.

View File

@ -0,0 +1,11 @@
contract C {
function f() external pure {
string[2] memory a1 = [hex'74000001', hex'c0a80101'];
string[2] memory a2 = [bytes(hex'74000001'), bytes(hex'c0a80101')];
bytes[2] memory a3 = [hex'74000001', hex'c0a80101'];
bytes[2] memory a4 = ['foo', 'bar'];
}
}
// ----
// TypeError 9574: (54-106): Type inline_array(literal_string hex"74000001", literal_string hex"c0a80101") is not implicitly convertible to expected type string memory[2] memory. Invalid conversion from literal_string hex"c0a80101" to string memory. Contains invalid UTF-8 sequence at position 4.
// TypeError 9574: (116-182): Type inline_array(bytes memory, bytes memory) is not implicitly convertible to expected type string memory[2] memory. Invalid conversion from bytes memory to string memory.