Merge pull request #9412 from ethereum/unicode-string

[BREAKING] Support unicode string literal type
This commit is contained in:
chriseth
2020-07-28 11:42:23 +02:00
committed by GitHub
32 changed files with 794 additions and 29 deletions
@@ -1,3 +1,4 @@
contract C {
string s = "\xf0\x9f\xa6\x84";
}
// ----
@@ -0,0 +1,9 @@
contract test {
function f() public pure returns (string memory) {
return "hello world";
}
function g() public pure returns (string memory) {
return unicode"hello world";
}
}
// ----
@@ -0,0 +1,7 @@
contract test {
function f() public pure returns (bytes32) {
bytes32 escapeCharacters = unicode"foo" unicode"😃, 😭, and 😈" unicode"!";
return escapeCharacters;
}
}
// ----
@@ -0,0 +1,8 @@
contract test {
function f() public pure returns (bytes32) {
bytes32 escapeCharacters = "foo" hex"aa" unicode"😃, 😭, and 😈" "!" hex"00";
return escapeCharacters;
}
}
// ----
// ParserError 2314: (106-113): Expected ';' but got 'HexStringLiteral'
@@ -1,6 +1,6 @@
contract test {
function f() public pure returns (string memory) {
return "😃, 😭, and 😈";
return unicode"😃, 😭, and 😈";
}
}
// ----
@@ -0,0 +1,7 @@
contract test {
function f() public pure returns (string memory) {
return "😃, 😭, and 😈";
}
}
// ----
// ParserError 8936: (86-88): Invalid character in string.
@@ -19,3 +19,4 @@ contract test {
return res;
}
}
// ----