From 9cf5a047bc1a475b666323890efb63e3f380b6bc Mon Sep 17 00:00:00 2001 From: asolana <110843012+ksolana@users.noreply.github.com> Date: Sat, 12 Aug 2023 15:50:32 -0700 Subject: [PATCH 1/4] [move-compiler] Fixed abstract interpreter bug with continue statement (#1069) continue in while loop causes an unexpected error. Cherry-pick: MystenLabs/sui#13349 Bugfix: move-language#1068 --- language/move-compiler/src/cfgir/absint.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/language/move-compiler/src/cfgir/absint.rs b/language/move-compiler/src/cfgir/absint.rs index 1ad6c3ff63..35a8ba4050 100644 --- a/language/move-compiler/src/cfgir/absint.rs +++ b/language/move-compiler/src/cfgir/absint.rs @@ -120,13 +120,14 @@ pub trait AbstractInterpreter: TransferFunctions { // the same post } JoinResult::Changed => { + // Pre has changed, the post condition is now unknown for the block + next_block_invariant.post = BlockPostcondition::Unprocessed; // If the cur->successor is a back edge, jump back to the beginning // of the loop, instead of the normal next block if cfg.is_back_edge(block_label, *next_block_id) { next_block_candidate = Some(*next_block_id); + break; } - // Pre has changed, the post condition is now unknown for the block - next_block_invariant.post = BlockPostcondition::Unprocessed } } } From 460f2a9a8f12b36782bc818ddb5d05c64193236e Mon Sep 17 00:00:00 2001 From: Joe Chen Date: Sun, 20 Aug 2023 04:55:18 +0800 Subject: [PATCH 2/4] [move-stdlib] formatting the string module codes (#1070) * [move-stdlib] formatting the string module codes * generate the docs --- language/move-stdlib/docs/string.md | 6 +++--- language/move-stdlib/sources/string.move | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/language/move-stdlib/docs/string.md b/language/move-stdlib/docs/string.md index e962b56d86..eae6e89293 100644 --- a/language/move-stdlib/docs/string.md +++ b/language/move-stdlib/docs/string.md @@ -101,7 +101,7 @@ Creates a new string from a sequence of bytes. Aborts if the bytes do not repres
public fun utf8(bytes: vector<u8>): String {
     assert!(internal_check_utf8(&bytes), EINVALID_UTF8);
-    String{bytes}
+    String { bytes }
 }
 
@@ -127,7 +127,7 @@ Tries to create a new string from a sequence of bytes.
public fun try_utf8(bytes: vector<u8>): Option<String> {
     if (internal_check_utf8(&bytes)) {
-        option::some(String{bytes})
+        option::some(String { bytes })
     } else {
         option::none()
     }
@@ -321,7 +321,7 @@ guaranteeing that the result is valid utf8.
         j <= l && i <= j && internal_is_char_boundary(bytes, i) && internal_is_char_boundary(bytes, j),
         EINVALID_INDEX
     );
-    String{bytes: internal_sub_string(bytes, i, j)}
+    String { bytes: internal_sub_string(bytes, i, j) }
 }
 
diff --git a/language/move-stdlib/sources/string.move b/language/move-stdlib/sources/string.move index bf9a74faba..14c3c5144e 100644 --- a/language/move-stdlib/sources/string.move +++ b/language/move-stdlib/sources/string.move @@ -17,13 +17,13 @@ module std::string { /// Creates a new string from a sequence of bytes. Aborts if the bytes do not represent valid utf8. public fun utf8(bytes: vector): String { assert!(internal_check_utf8(&bytes), EINVALID_UTF8); - String{bytes} + String { bytes } } /// Tries to create a new string from a sequence of bytes. public fun try_utf8(bytes: vector): Option { if (internal_check_utf8(&bytes)) { - option::some(String{bytes}) + option::some(String { bytes }) } else { option::none() } @@ -77,7 +77,7 @@ module std::string { j <= l && i <= j && internal_is_char_boundary(bytes, i) && internal_is_char_boundary(bytes, j), EINVALID_INDEX ); - String{bytes: internal_sub_string(bytes, i, j)} + String { bytes: internal_sub_string(bytes, i, j) } } /// Computes the index of the first occurrence of a string. Returns `length(s)` if no occurrence found. From 7188f31f3328e713acfc4bcb6790e0bb63399706 Mon Sep 17 00:00:00 2001 From: Joe Chen Date: Sun, 20 Aug 2023 04:55:36 +0800 Subject: [PATCH 3/4] [move-book-zh] fix some typos in generics chapter (#1067) --- .../book/translations/move-book-zh/src/generics.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/language/documentation/book/translations/move-book-zh/src/generics.md b/language/documentation/book/translations/move-book-zh/src/generics.md index c5553d2693..888ca5df47 100644 --- a/language/documentation/book/translations/move-book-zh/src/generics.md +++ b/language/documentation/book/translations/move-book-zh/src/generics.md @@ -269,7 +269,7 @@ struct Bar { x: Foo } // ^ 错误!u8 没有 'key' struct Baz { x: Foo } -// ^ 错误! t 没有 'key' +// ^ 错误! T 没有 'key' ``` ```move @@ -287,7 +287,7 @@ fun consume(x: T) { fun foo() { let r = R {}; consume(r); - // ^ 错误!r 没有 'drop' + // ^ 错误!R 没有 'drop' } ``` @@ -306,7 +306,7 @@ fun double(x: T) { fun foo(): (R, R) { let r = R {}; double(r) - // ^ 错误!R 没有 'error' + // ^ 错误!R 没有 'copy' } ``` From ea70797099baea64f05194a918cebd69ed02b285 Mon Sep 17 00:00:00 2001 From: EarthCompass Date: Mon, 21 Aug 2023 11:19:40 +0800 Subject: [PATCH 4/4] [language] Fix the doc of CastU64 --- language/move-binary-format/src/file_format.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/language/move-binary-format/src/file_format.rs b/language/move-binary-format/src/file_format.rs index 4beacfbf91..0be6b85fb8 100644 --- a/language/move-binary-format/src/file_format.rs +++ b/language/move-binary-format/src/file_format.rs @@ -1210,7 +1210,7 @@ pub enum Bytecode { /// /// Stack transition: /// - /// ```..., integer_value -> ..., u8_value``` + /// ```..., integer_value -> ..., u64_value``` CastU64, /// Convert the value at the top of the stack into u128. ///