Skip to content

mruby-exit: SystemExit.new takes a status; SystemExit#success? - #7791

Merged
matz merged 1 commit into
mruby:masterfrom
amatsuda:system-exit-status
Nov 10, 2026
Merged

matz merged 1 commit into
mruby:masterfrom
amatsuda:system-exit-status

Conversation

@amatsuda

@amatsuda amatsuda commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

SystemExit.new didn't take a status: the argument became the message, and the status was nil unless Kernel#exit had set it:

SystemExit.new(3).status    # nil (message "3"); CRuby: 3
SystemExit.new.status       # nil; CRuby: 0
SystemExit.new.success?     # NoMethodError

As in CRuby, a leading true, false or Integer is now the status (true is 0, false is 1), the message may follow it, and without one the status is 0. SystemExit#success? answers whether the status is 0. Kernel#exit still sets the status itself, so it is unchanged.

Tested with MRUBY_CONFIG=ci/gcc-clang rake test (KO 0, Crash 0).

🤖 Generated with Claude Code

https://claude.ai/code/session_01X4cowTc1oGMNQfUma7zNdD

Summary by CodeRabbit

  • New Features
    • SystemExit now accepts a status and optional message, with true and false mapped to statuses 0 and 1. It defaults to status 0 when given a non-status argument and reports invalid argument combinations with ArgumentError.
  • Documentation
    • Added documentation for the SystemExit constructor and its status and success methods.

SystemExit.new(3) took 3 for the message and left status nil, and
SystemExit.new had no status either; only Kernel#exit set one. As in
CRuby, a leading true, false or Integer is now the status (true being 0
and false 1), the message may follow, and the status is 0 without one.
SystemExit#success? answers whether the status is 0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X4cowTc1oGMNQfUma7zNdD
@amatsuda
amatsuda requested a review from matz as a code owner November 10, 2026 03:19
@coderabbitai

coderabbitai Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

SystemExit#initialize(*args) now handles status and message arguments, maps booleans and integers to statuses, and raises ArgumentError for invalid argument counts. Documentation and tests cover constructor behavior and success?.

Changes: SystemExit Construction

Layer / File(s) Summary
Constructor behavior and validation
mrbgems/mruby-exit/mrblib/mruby_exit.rb, mrbgems/mruby-exit/test/exit.rb
SystemExit#initialize(*args) maps true, false, and integers to statuses, supports a message argument, and raises ArgumentError for invalid argument counts. Documentation describes the constructor, status, and success?. Tests cover construction and success? results, including exceptions raised by exit.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested labels: mrbgems

Merge Risk: Minimal · up to 26a07

This change adds status and message handling to SystemExit.new, plus a success? check, with tests. No merge-blocking risk was found.

Pre-merge checks: Passed 5

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly identifies the changes to SystemExit.new and SystemExit#success?.
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 1 functions across 2 files.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 17c7b414-389c-40fe-b035-75859a0ee1f7
Commits

Reviewing files that changed from the base of the PR and between 1de7c48 and 26a07ad.

Files selected for processing: 2

  • mrbgems/mruby-exit/mrblib/mruby_exit.rb
  • mrbgems/mruby-exit/test/exit.rb

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 5 remain after this review.

@matz
matz merged commit b8ce589 into mruby:master Nov 10, 2026
23 checks passed
@coderabbitai coderabbitai Bot mentioned this pull request Nov 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants