Skip to content

internal: add virtual pkg "moonbitlang/core/panic" #2016

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Young-Flash
Copy link
Contributor

No description provided.

Copy link

peter-jerry-ye-code-review bot commented Apr 27, 2025

Message parameter in abort() is ignored

Category
Correctness
Code Snippet
pub fn abort[T](msg : String) -> T {
let _ = msg
panic()
}
Recommendation
The error message should be logged or displayed before panicking. Consider using a system logging function or stderr output before calling panic()
Reasoning
Currently the error message parameter is completely ignored (bound to _ and never used). This defeats the purpose of having a message parameter since the error context will be lost.

Missing documentation for panic() function

Category
Maintainability
Code Snippet
pub fn panicT -> T {
@intrinsics.unreachable()
}
Recommendation
Add documentation comments explaining the purpose and behavior of the panic() function, similar to how abort() is documented
Reasoning
Consistent documentation helps maintainers and users understand the purpose and behavior of public APIs. The panic() function is public but lacks explanatory comments.

Package organization could be improved

Category
Maintainability
Code Snippet
"import": [
"moonbitlang/core/panic"
],
Recommendation
Consider moving panic-related functionality to a more general error handling module that could also include other error handling mechanisms in the future
Reasoning
While separating panic into its own module is good, it might make more sense as part of a broader error handling module that could include other error handling patterns in the future. This would provide a more cohesive organization of error-related functionality.

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.

1 participant