Skip to content

Commit 3b4dacf

Browse files
fxnbyroot
authored andcommitted
Let the docs of base_label and label be similar
1 parent dadaa11 commit 3b4dacf

File tree

1 file changed

+24
-7
lines changed

1 file changed

+24
-7
lines changed

vm_backtrace.c

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -287,15 +287,14 @@ location_label(rb_backtrace_location_t *loc)
287287
* 1.times do
288288
* puts caller_locations(0).first.label
289289
* end
290-
*
291290
* end
292291
* end
293292
*
294293
* The result of calling +foo+ is this:
295294
*
296-
* label: foo
297-
* label: block in foo
298-
* label: block (2 levels) in foo
295+
* foo
296+
* block in foo
297+
* block (2 levels) in foo
299298
*
300299
*/
301300
static VALUE
@@ -315,10 +314,28 @@ location_base_label(rb_backtrace_location_t *loc)
315314
}
316315

317316
/*
318-
* Returns the label of this frame without decoration.
317+
* Returns the base label of this frame, which is usually equal to the label,
318+
* without decoration.
319+
*
320+
* Consider the following example:
321+
*
322+
* def foo
323+
* puts caller_locations(0).first.base_label
324+
*
325+
* 1.times do
326+
* puts caller_locations(0).first.base_label
327+
*
328+
* 1.times do
329+
* puts caller_locations(0).first.base_label
330+
* end
331+
* end
332+
* end
333+
*
334+
* The result of calling +foo+ is this:
319335
*
320-
* For example, if the label is `foo`, this method returns `foo` as well, but if
321-
* the label is +rescue in foo+, this method returns just +foo+.
336+
* foo
337+
* foo
338+
* foo
322339
*/
323340
static VALUE
324341
location_base_label_m(VALUE self)

0 commit comments

Comments
 (0)