mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Mark string literals as not implicitly convertible to calldata arrays
This commit is contained in:
+9
@@ -0,0 +1,9 @@
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
contract C {
|
||||
function f() public pure returns(string[5] calldata) {
|
||||
return ["h", "e", "l", "l", "o"];
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError 6359: (122-147): Return argument type string memory[5] memory is not implicitly convertible to expected type (type of first return variable) string calldata[5] calldata.
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
contract C {
|
||||
function f1() public pure returns(string calldata) {
|
||||
return "hello";
|
||||
}
|
||||
|
||||
function f2() public pure returns(string calldata) {
|
||||
return unicode"hello";
|
||||
}
|
||||
|
||||
function f3() public pure returns(bytes calldata) {
|
||||
return hex"68656c6c6f";
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError 6359: (85-92): Return argument type literal_string "hello" is not implicitly convertible to expected type (type of first return variable) string calldata.
|
||||
// TypeError 6359: (173-187): Return argument type literal_string "hello" is not implicitly convertible to expected type (type of first return variable) string calldata.
|
||||
// TypeError 6359: (267-282): Return argument type literal_string "hello" is not implicitly convertible to expected type (type of first return variable) bytes calldata.
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
contract C {
|
||||
function g(string calldata _s) public {}
|
||||
function h(bytes calldata _b) public {}
|
||||
|
||||
function f() public {
|
||||
g("hello");
|
||||
g(unicode"hello");
|
||||
h(hex"68656c6c6f");
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError 9553: (139-146): Invalid type for argument in function call. Invalid implicit conversion from literal_string "hello" to string calldata requested.
|
||||
// TypeError 9553: (159-173): Invalid type for argument in function call. Invalid implicit conversion from literal_string "hello" to string calldata requested.
|
||||
// TypeError 9553: (186-201): Invalid type for argument in function call. Invalid implicit conversion from literal_string "hello" to bytes calldata requested.
|
||||
Reference in New Issue
Block a user