moonbitlang / moon

The build system and package manager for MoonBit
https://moonbitlang.github.io/moon/
GNU Affero General Public License v3.0
140 stars 11 forks source link

fix upgrade #253

Closed Young-Flash closed 1 week ago

Young-Flash commented 1 week ago

close https://github.com/moonbitlang/moon/issues/250 and add error handling for get version (https://github.com/moonbitlang/moon/issues/241)

peter-jerry-ye-code-review[bot] commented 1 week ago
  1. Potential Unwrap of Result without Handling Errors:

    • In crates/moon/src/cli/version.rs, the use of ? on moonc_version and moonrun_version suggests that these are Result types. However, the original code did not handle potential errors, which could lead to runtime crashes if the versions cannot be retrieved.
    • Example: println!("moonc {}", moonc_version?);
  2. Inconsistent Error Handling:

    • In crates/moonutil/src/common.rs, the functions get_moonc_version and get_moonrun_version were modified to return anyhow::Result<String>, yet in other parts of the code, such as crates/moonutil/src/dirs.rs, these functions are called without handling the potential errors.
    • Example: moonc_version: get_moonc_version().unwrap(),
  3. Duplicate Print Statements:

    • In crates/moon/src/cli/version.rs, there are duplicate print statements for moonc, which might be a typo or indicate a mistake in the logic.
    • Example:
      println!("moonc {}", moonc_version?);
      println!("moonc {}", moonrun_version?);

      These lines are repeated in the code block under different conditions, which might not be intended.