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 without logging

Category
Correctness
Code Snippet
pub fn abort[T](msg : String) -> T {
let _ = msg
panic()
}
Recommendation
Consider logging the message before panicking:

pub fn abort[T](msg : String) -> T {
  // Add logging here if available
  print(msg) // or equivalent logging mechanism
  panic()
}

Reasoning
The current implementation silently ignores the error message parameter. Error messages are crucial for debugging, and discarding them reduces the utility of the abort function.

Documentation needs updating after refactoring

Category
Maintainability
Code Snippet
///|
/// Aborts the program. Always causes a panic, regardless of the message provided.
Recommendation
Add back the complete documentation including parameters section and example usage as it was in the original code
Reasoning
The documentation was significantly reduced during the refactoring. While the code is simpler, maintaining comprehensive documentation is important for API users.

Function alias declarations lack documentation

Category
Maintainability
Code Snippet
pub fnalias @panic.panic
pub fnalias @panic.abort
Recommendation
Add documentation comments explaining that these are aliases to the new panic module implementations:

///|
/// Alias to panic module's panic function
pub fnalias @panic.panic

Reasoning
Function aliases should be documented to maintain code clarity and help developers understand the relationship between the old and new implementations.

@Young-Flash Young-Flash force-pushed the virtual_panic_pkg branch 5 times, most recently from 68c5d33 to 24abc4e Compare April 29, 2025 03:39
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