Skip to content

Conversation

hackwaly
Copy link
Contributor

@hackwaly hackwaly commented Sep 8, 2025

No description provided.

@hackwaly hackwaly force-pushed the yuxiang/add-divided-by-zero-check branch from 27fda51 to 2da4e33 Compare September 8, 2025 05:46
@coveralls
Copy link
Collaborator

coveralls commented Sep 8, 2025

Pull Request Test Coverage Report for Build 1129

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 89.357%

Totals Coverage Status
Change from base Build 1125: 0.0%
Covered Lines: 8807
Relevant Lines: 9856

💛 - Coveralls

Copy link

Division by zero check condition may be inefficient and unclear

Category
Correctness
Code Snippet
guard not(other.hi == 0 && other.lo == 0) else { panic() }
Recommendation
Consider adding a helper method is_zero() to MyInt64 and use guard not(other.is_zero()) else { panic() } or implement an Eq trait to use guard other != 0L else { panic() }
Reasoning
The current condition other.hi == 0 && other.lo == 0 is repeated 4 times and could be more readable. A helper method would improve maintainability and make the intent clearer.

Test functions are missing proper panic assertions

Category
Maintainability
Code Snippet
test "panic 1L / 0L" {
let _ = 1L / 0L

}
Recommendation
Use proper panic testing syntax if available in MoonBit, such as @test.should_panic annotation or wrap in a try-catch block to verify the panic occurs
Reasoning
The current tests don't actually verify that a panic occurs - they just perform the operation. Without proper panic assertions, these tests may not catch regressions where the panic is accidentally removed.

Duplicated code across division and modulo operations

Category
Maintainability
Code Snippet
guard not(other.hi == 0 && other.lo == 0) else { panic() }
let exports = get_int64_wasm_helper()
let { hi: ahi, lo: alo } = self
let { hi: bhi, lo: blo } = other
Recommendation
Extract the zero check and parameter setup into a private helper function that can be reused across all division/modulo operations
Reasoning
The same guard clause and variable destructuring pattern is repeated in 4 different functions, violating DRY principle. A helper function would reduce code duplication and make maintenance easier.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants