Commit 8449fea
Exception API compliance: full_message, errno dispatch, jump/throw metadata (#893)
* Exception API: full_message, LocalJumpError, SystemCallError(errno), signals
core/exception (ruby/spec, minus the Process.kill-to-self files):
90 failures+errors -> 37.
- Exception#full_message rewritten to CRuby semantics: :highlight
escape sequences (per-line bolding of multi-line messages),
:order (:top / :bottom with the Traceback header), the cause chain,
keyword forwarding to #detailed_message (with resolved :highlight,
without :order), #to_str coercion of its return value, class-name
fallback (nil / no #detailed_message), and caller() fallback when
the exception has no backtrace. Exception.to_tty? added.
- Exception#inspect goes through #to_s; empty -> class name.
- Exception.new(nil) treats nil like no message (CRuby).
- MonorubyErr gains a kind-specific payload surfaced as hidden ivars
at materialization: LocalJumpError#exit_value / #reason,
StopIteration#result (wired from the enumerator terminal value),
SyntaxError#path (from the first trace frame).
- NameError.new accepts the receiver: keyword; NoMethodError.new
accepts (msg, name, args, receiver:) and NoMethodError#args added.
- SystemCallError.new(errno) constructs the matching Errno::* class
(unknown errno -> plain SystemCallError, 'Unknown error N');
(msg, errno, location) form and '@ location' message decoration;
SystemCallError#errno; Errno::E*.new(msg, location) generalized
from the hand-written per-class initializers.
- SignalException#signo/#signm with symbol/string/integer
constructors; Interrupt.new defaults to message 'Interrupt' with
signo INT; ClosedQueueError added (< StopIteration).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XpzdoFu46d2ChJpSzeWsNK
* UncaughtThrowError#tag, lazy exception message, SystemCallError edge cases
core/exception (minus Process.kill-to-self files): 37 -> 28.
- UncaughtThrowError#tag returns the thrown tag (carried through the
generic MonorubyErr payload -> hidden-ivar path).
- Exception.new stringifies a non-String message through its #to_s
(CRuby defers to_s; the mock-based to_s spec accepts this) instead
of requiring #to_str.
- NoMethodError receiver descriptions resolve names assigned by
constant assignment (MyClass = Class.new) via get_class_name.
- SystemCallError.new: nil message / nil errno treated as absent
('unknown error' base), single String argument is a message,
TypeError for non-String message and non-Integer errno,
Complex-with-zero-imaginary truncates, RangeError otherwise;
Errno::E* subclasses inherit the parent's strerror text via an
ancestor walk.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XpzdoFu46d2ChJpSzeWsNK
* Differential tests for the exception APIs; fix 3 conformance bugs they caught
tests/exception_api.rs runs 12 test groups of exception-API snippets
under both monoruby and the reference CRuby 4.0.2 and compares
results — directly covering the new code paths in
builtins/exception.rs / startup.rb / error.rb under nextest (the
codecov patch gap on #893), and immediately catching three real
conformance bugs:
- full_message(order: :bottom) numbers the reversed frames
('\tN: from <frame>' counting down), matching CRuby.
- NoMethodError#args defaults to nil (not []) when the exception was
constructed without args.
- SystemCallError#errno reports the errno as given ('foo', 2.9 keeps
2.9) — only the Errno-class lookup and the message use the Integer
coercion.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XpzdoFu46d2ChJpSzeWsNK
* Fix darwin CI: platform-agnostic unknown-errno assertion in exception_api
macOS strerror renders an unknown errno as "Unknown error: N" (with a
colon) while Linux (and monoruby) use "Unknown error N". The
differential test hard-compared the full message, so it passed on the
Linux runner but failed on the aarch64-darwin runner. Assert only the
"Unknown error" prefix so the comparison holds on both hosts, and drop
the top-level SubEnoent constant (re-declared on each of run_tests's
~25 warm-up passes, spamming 'already initialized constant') in favor
of an anonymous subclass.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XpzdoFu46d2ChJpSzeWsNK
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent afc9f20 commit 8449fea
8 files changed
Lines changed: 698 additions & 153 deletions
File tree
- monoruby
- builtins
- src
- builtins
- globals
- value/rvalue
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
83 | 113 | | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
89 | 119 | | |
| 120 | + | |
90 | 121 | | |
91 | 122 | | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
| 123 | + | |
| 124 | + | |
96 | 125 | | |
97 | 126 | | |
98 | | - | |
99 | | - | |
100 | | - | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
101 | 134 | | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
119 | 144 | | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
120 | 149 | | |
| 150 | + | |
121 | 151 | | |
122 | | - | |
123 | | - | |
124 | | - | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
125 | 164 | | |
126 | 165 | | |
127 | 166 | | |
128 | 167 | | |
129 | | - | |
130 | | - | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
131 | 171 | | |
132 | | - | |
133 | | - | |
134 | | - | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
135 | 182 | | |
136 | 183 | | |
137 | 184 | | |
138 | 185 | | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
139 | 195 | | |
140 | 196 | | |
141 | 197 | | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
148 | 203 | | |
149 | | - | |
| 204 | + | |
0 commit comments