-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[move-compiler-v2] Print a better error message for a string without …
- Loading branch information
1 parent
e87224f
commit 208988e
Showing
19 changed files
with
171 additions
and
2 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
third_party/move/move-compiler-v2/tests/folding/constants_hexstring.exp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
|
||
Diagnostics: | ||
error: invalid hex string | ||
┌─ tests/folding/constants_hexstring.move:6:29 | ||
│ | ||
6 │ const C12: vector<u8> = x"hello"; | ||
│ ^^^^^^^^ Odd number of characters in hex string. Expected 2 hexadecimal digits for each byte | ||
|
||
error: invalid hex string | ||
┌─ tests/folding/constants_hexstring.move:7:31 | ||
│ | ||
7 │ const C13: vector<u8> = x"hello!"; | ||
│ ^ Invalid hexadecimal character: 'h' |
9 changes: 9 additions & 0 deletions
9
third_party/move/move-compiler-v2/tests/folding/constants_hexstring.move
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
address 0x42 { | ||
module M { | ||
fun u(): u64 { 0 } | ||
|
||
const C11: vector<u8> = x"deadbeef"; | ||
const C12: vector<u8> = x"hello"; | ||
const C13: vector<u8> = x"hello!"; | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
third_party/move/move-compiler-v2/tests/folding/constants_quoted_string.exp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
|
||
Diagnostics: | ||
error: invalid byte string | ||
┌─ tests/folding/constants_quoted_string.move:5:29 | ||
│ | ||
5 │ const C12: vector<u8> = "<empty>"; | ||
│ ^ String literal must begin with b" (for a byte string) or x" (for a hex string) |
8 changes: 8 additions & 0 deletions
8
third_party/move/move-compiler-v2/tests/folding/constants_quoted_string.move
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
address 0x42 { | ||
module M { | ||
fun u(): u64 { 0 } | ||
|
||
const C12: vector<u8> = "<empty>"; | ||
const C13: vector<u8> = "foo; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
third_party/move/move-compiler-v2/tests/folding/constants_single_quote.exp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
|
||
Diagnostics: | ||
error: invalid character | ||
┌─ tests/folding/constants_single_quote.move:4:29 | ||
│ | ||
4 │ const C13: vector<u8> = "foo | ||
│ ^ Invalid character: '"'; string literal must begin with `b"` and closing quote `"` must appear on same line |
10 changes: 10 additions & 0 deletions
10
third_party/move/move-compiler-v2/tests/folding/constants_single_quote.move
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
address 0x42 { | ||
module M { | ||
fun u(): u64 { 0 } | ||
const C13: vector<u8> = "foo | ||
"; | ||
const C14: vector<u8> = "bar"; | ||
const C15: vector<u8> = b"baz"; | ||
const C16: vector<u8> = x"quux"; | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
third_party/move/move-compiler-v2/tests/folding/constants_string_non_utf8.exp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
|
||
Diagnostics: | ||
error: invalid character | ||
┌─ tests/folding/constants_string_non_utf8.move:5:31 | ||
│ | ||
5 │ const C12: vector<u8> = b"ÿ"; | ||
│ ^ Invalid character 'ÿ' found when reading file. Only ASCII printable characters, tabs (\t), lf (\n) and crlf (\r\n) are permitted. |
7 changes: 7 additions & 0 deletions
7
third_party/move/move-compiler-v2/tests/folding/constants_string_non_utf8.move
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
address 0x42 { | ||
module M { | ||
fun u(): u64 { 0 } | ||
|
||
const C12: vector<u8> = b"ÿ"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
third_party/move/move-compiler/tests/move_check/parser/constants_hexstring.exp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
error[E01008]: invalid hex string | ||
┌─ tests/move_check/parser/constants_hexstring.move:6:29 | ||
│ | ||
6 │ const C12: vector<u8> = x"hello"; | ||
│ ^^^^^^^^ Odd number of characters in hex string. Expected 2 hexadecimal digits for each byte | ||
|
||
error[E08001]: cannot compute constant value | ||
┌─ tests/move_check/parser/constants_hexstring.move:6:29 | ||
│ | ||
6 │ const C12: vector<u8> = x"hello"; | ||
│ ^^^^^^^^ Invalid expression in 'const'. This expression could not be evaluated to a value | ||
|
||
error[E08001]: cannot compute constant value | ||
┌─ tests/move_check/parser/constants_hexstring.move:7:29 | ||
│ | ||
7 │ const C13: vector<u8> = x"hello!"; | ||
│ ^^^^^^^^^ Invalid expression in 'const'. This expression could not be evaluated to a value | ||
|
||
error[E01008]: invalid hex string | ||
┌─ tests/move_check/parser/constants_hexstring.move:7:31 | ||
│ | ||
7 │ const C13: vector<u8> = x"hello!"; | ||
│ ^ Invalid hexadecimal character: 'h' | ||
|
9 changes: 9 additions & 0 deletions
9
third_party/move/move-compiler/tests/move_check/parser/constants_hexstring.move
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
address 0x42 { | ||
module M { | ||
fun u(): u64 { 0 } | ||
|
||
const C11: vector<u8> = x"deadbeef"; | ||
const C12: vector<u8> = x"hello"; | ||
const C13: vector<u8> = x"hello!"; | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
third_party/move/move-compiler/tests/move_check/parser/constants_quoted_string.exp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
error[E01007]: invalid byte string | ||
┌─ tests/move_check/parser/constants_quoted_string.move:5:29 | ||
│ | ||
5 │ const C12: vector<u8> = "<empty>"; | ||
│ ^ String literal must begin with b" (for a byte string) or x" (for a hex string) | ||
|
8 changes: 8 additions & 0 deletions
8
third_party/move/move-compiler/tests/move_check/parser/constants_quoted_string.move
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
address 0x42 { | ||
module M { | ||
fun u(): u64 { 0 } | ||
|
||
const C12: vector<u8> = "<empty>"; | ||
const C13: vector<u8> = "foo; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
third_party/move/move-compiler/tests/move_check/parser/constants_single_quote.exp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
error[E01001]: invalid character | ||
┌─ tests/move_check/parser/constants_single_quote.move:4:29 | ||
│ | ||
4 │ const C13: vector<u8> = "foo | ||
│ ^ Invalid character: '"'; string literal must begin with `b"` and closing quote `"` must appear on same line | ||
|
10 changes: 10 additions & 0 deletions
10
third_party/move/move-compiler/tests/move_check/parser/constants_single_quote.move
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
address 0x42 { | ||
module M { | ||
fun u(): u64 { 0 } | ||
const C13: vector<u8> = "foo | ||
"; | ||
const C14: vector<u8> = "bar"; | ||
const C15: vector<u8> = b"baz"; | ||
const C16: vector<u8> = x"quux"; | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
third_party/move/move-compiler/tests/move_check/parser/constants_string_non_utf8.exp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
error[E01001]: invalid character | ||
┌─ tests/move_check/parser/constants_string_non_utf8.move:5:31 | ||
│ | ||
5 │ const C12: vector<u8> = b"ÿ"; | ||
│ ^ Invalid character 'ÿ' found when reading file. Only ASCII printable characters, tabs (\t), lf (\n) and crlf (\r\n) are permitted. | ||
|
7 changes: 7 additions & 0 deletions
7
third_party/move/move-compiler/tests/move_check/parser/constants_string_non_utf8.move
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
address 0x42 { | ||
module M { | ||
fun u(): u64 { 0 } | ||
|
||
const C12: vector<u8> = b"ÿ"; | ||
} | ||
} |