Граф коммитов

594 Коммитов

Автор SHA1 Сообщение Дата
Kazuhiro NISHIYAMA 2e67043041
Use UNREACHABLE instead of fall through 2021-07-20 14:46:46 +09:00
Kazuhiro NISHIYAMA 036f26a4e2
Add `fall through`
Pointed out by Coverity Scan

```
** CID 1487522: Control flow issues (MISSING_BREAK)
/error.c: 1273 in exc_full_message()
```
2021-07-19 17:21:45 +09:00
Nobuyoshi Nakada 8a6ef5ef8f
Make boolean expected messages more consitent 2021-07-18 20:51:30 +09:00
Nobuyoshi Nakada 94bd3bde81 Specify version to remove as bare numbers 2021-06-30 10:47:01 +09:00
Nobuyoshi Nakada 0b726924a4 Show the removal version 2021-06-30 10:47:01 +09:00
Nobuyoshi Nakada 8118d435d0 rb_warn_deprecated_to_remove_at [Feature #17432]
At compilation time with RUBY_DEBUG enabled, check if the removal
version has been reached.
2021-06-30 10:47:01 +09:00
Adam Daniels f64d7674f6 Fix example for custom warn method
Regexp has a match? method.

[ci skip]
2021-04-30 17:13:04 -07:00
S-H-GAMELINKS e398a0e53a Remove unneeded rb_ident_hash_new function declaration 2021-03-28 08:50:25 +09:00
Kenichi Kamiya 0a544c0c35
Fix segmentation fault when `Module#name` returns non string value [Bug #17754]
* Add test for NoMethodError#to_s does not segfault

* Ensure no segfault even if Module#name is overridden
2021-03-28 08:47:42 +09:00
Garen Torikian 34c422b678 Fix grammatical error 2021-02-06 13:02:17 -05:00
Nobuyoshi Nakada 1cdae49d39 Implement NameError::message#clone for Ractor 2021-02-01 19:54:21 +09:00
xtkoba (Tee KOBAYASHI) 0e5fbec816
Fixed varargs in `rb_bug_without_die` [Bug #17603] 2021-02-01 13:47:35 +09:00
Nobuyoshi Nakada 2556cd3f51 Bypass check for warning_category on internal calls 2020-12-28 12:44:03 +09:00
Kazuki Tsujimoto 31b17a14ab
Make NoMatchingPatternError a subclass of StandardError 2020-12-23 02:31:02 +09:00
卜部昌平 c30f03d328 Data: delete
Has been deprecated since 684bdf6171.

Matz says in [ruby-core:83954] that Data should be an alias of Object.
Because rb_cData has not been deprecated, let us deprecate the constant
to make it a C-level synonym of rb_cObject.
2020-12-22 02:51:49 +09:00
Jeremy Evans 7e2dbbda35 Use category: :experimental in warnings that are related to experimental features
This adds rb_category_compile_warn in order to emit compiler warnings
with categories.  Note that Ripper currently ignores the category
for these warnings, but by default it ignores the warnings completely,
so this shouldn't matter.
2020-12-18 09:54:11 -08:00
Jeremy Evans 6ced55b07c Make warning_categories a map of category symbols to category numbers
Use this to simplify rb_warning_category_from_name.

This also adds support for using the :experimental category in
Kernel#warn and Warning.warn.
2020-12-18 09:54:11 -08:00
Jeremy Evans 52fb696ee7 Switch rb_category_warn{,ing} to accept an rb_warning_category_t
Since we decided to only allowing specific warning categories,
there is no reason to have an API that accepts a general string,
as it is more error-prone.  Switch to only allowing the specific
warning categories.

As rb_category_warn{,ing} are public API, this requires making
rb_warning_category_t public API as well.
2020-12-18 09:54:11 -08:00
Nobuyoshi Nakada ce6fafb8cc
Cache warning category IDs 2020-12-15 15:19:23 +09:00
Alan Wu befa24488c Help RDoc find Exception [ci skip]
This was on top of `Init_Exception()`.
2020-12-14 20:01:01 -05:00
Nobuyoshi Nakada 2749123e21
Supported category option in Warning#warn 2020-12-08 22:50:45 +09:00
Nobuyoshi Nakada d7a16670c3
[DOC] Fixed RDoc directives [ci skip] 2020-12-08 18:02:31 +09:00
Takashi Kokubun 4dbf6f1e51
Call rb_bug_without_die on CI
when GC.compact's SEGV handler is installed
2020-11-26 20:09:57 -08:00
Benoit Daloze cffdacb15a Ignore <internal: entries from core library methods for Kernel#warn(message, uplevel: n)
* Fixes [Bug #17259]
2020-10-26 08:47:33 +01:00
Nobuyoshi Nakada 5a77e90fe8
Use rb_intern_const instead of rb_intern in Init functions
```
find . -name \*.o -exec nm {} + |&
sed '/Init_.*\.rbimpl_id/!d;s/^.* b //;s/\.[1-9][0-9]*$//;s/\.rbimpl_id$//' |
uniq
```
should be empty.
2020-10-21 12:46:53 +09:00
Benoit Daloze d0778cb264 Update example to handle keywords passed to Warning.warn 2020-10-03 13:19:24 +02:00
Benoit Daloze 112254d185 Improve docs of the Warning module 2020-10-02 18:32:42 +02:00
Jeremy Evans 346301e232 Add rb_category_warn{,ing} for warning messages with categories
This adds the following C-API functions that can be used to emit
warnings with categories included:

```c
void rb_category_warn(const char *, const char*, ...)
void rb_category_warning(const char*, const char*, ...)
```

Internally in error.c, there is an rb_warn_category function
that will call Warning.warn with the string and the category
keyword if it doesn't have an arity of 1, and will call
Warning.warn with just the string if it has an arity of 1.
This refactors the rb_warn_deprecated{,_to_remove} functions
to use rb_warn_category.

This makes Kernel#warn accept a category keyword and pass it
to Warning.warn, so that Ruby methods can more easily emit
warnings with categories.  rb_warn_category makes sure that
the passed category is a already defined category symbol
before calling Warning.warn.

The only currently defined warning category is :deprecated,
since that is what is already used.  More categories can be
added in later commits.
2020-09-28 08:38:06 -07:00
Jeremy Evans 92c3ad9c27 Make Warning.warn accept only category keyword
In general accepting arbitrary keywords is a bad idea unless you are
delegating keywords or acting on arbitrary keywords.  In this case,
the category keyword is ignored, and it's less error prone to not
ignore all keywords.
2020-09-28 08:38:06 -07:00
Nobuyoshi Nakada 996af2ce08 Disable deprecation warning by the default [Feature #16345]
And `-w` option turns it on.
2020-09-25 09:50:33 +09:00
Kazuhiro NISHIYAMA b2b855f486
Fix `warning: instance variable bt_locations not initialized` 2020-09-15 14:03:41 +09:00
Kazuhiro NISHIYAMA f3754dfc2e
Fix missing `"` [ci skip] 2020-09-15 14:03:22 +09:00
Yusuke Endoh 369cfabd59 Make it possible to dump and load an exception object
A backtrace object in an exception had never supported marshalling
correctly: `Marshal.load(Marshal.dump(exc)).backtrace_locations` dumped
core.

An Exception object has two hidden instance varibles for backtrace data:
one is "bt", which has an Array of Strings, and the other is
"bt_locations", which has an Array of Thread::Backtrace::Locations.
However, Exception's dump outputs data so that the two variables are the
same Array of Strings. Thus, "bt_locations" had a wrong-type object.

For the compatibility, it is difficult to change the dump format.  This
changeset fixes the issue by ignoring data for "bt_locations" at the
loading phase if "bt_locations" refers to the same object as "bt".

Future work: Exception's dump should output "bt_locations"
appropriately.

https://bugs.ruby-lang.org/issues/17150
2020-09-06 13:57:41 +09:00
Nobuyoshi Nakada eeb5325d3b
Hoisted out warn_deprecated 2020-09-03 18:51:48 +09:00
eileencodes eada635033 Add category to `rb_warn_deprecated`
PR https://github.com/ruby/ruby/pull/3418 added a category to
`rb_warn_deprecated_to_remove` but not to `rb_warn_deprecated`. This
adds the same code to `rb_warn_deprecated` so that those warnings also
get a category.

This change also adds tests for `rb_warn_deprecated` and updates the
tests for `rb_warn_deprecated_to_remove` to have clearer names.

I've fixed the call to `rb_method_entry` as we need to be using the
instance method, not singleton.

Feature: https://bugs.ruby-lang.org/issues/17122
2020-09-02 12:44:33 -07:00
eileencodes 6e8ec9ab6d Support passing a category to `Warning.warn`
This change adds a `category` kwarg to make it easier to monkey patch
`Warning.warn`. Warnings already have a category, but that warning isn't
exposed. This implements a way to get the category so that warnings with
a specific category, like deprecated, can be treated differently than
other warnings in an application.

The change here does an arity check on the method to support backwards
compatibility for applications that may already have a warning monkey
patch.

For our usecase we want to `raise` for deprecation warnings in order to
get the behavior for the next Ruby version. For example, now that we
fixed all our warnings and deployed Ruby 2.7 to production, we want to
be able to have deprecation warnings behave like they would in 3.0: raise
an error. For other warnings, like uninialized constants, that behavior
won't be removed from Ruby in the next version, so we don't need to
raise errors.

Co-authored-by: Aaron Patterson <tenderlove@ruby-lang.org>
2020-09-01 16:16:06 -07:00
卜部昌平 de3e931df7 add UNREACHABLE_RETURN
Not every compilers understand that rb_raise does not return.  When a
function does not end with a return statement, such compilers can issue
warnings.  We would better tell them about reachabilities.
2020-06-29 11:05:41 +09:00
卜部昌平 801752f577 builtin_class_name: add variant that return VALUE
Found that `if (builtin_class_name) { printf } else { printf }` happens
twice.  It would be better if we could eliminate those if statements.
2020-06-29 11:05:41 +09:00
卜部昌平 a2677815f5 rb_check_typeddata: do not goto into a branch
I'm not necessarily against every goto in general, but jumping into a
branch is definitely a bad idea.  Better refactor.
2020-06-29 11:05:41 +09:00
Nobuyoshi Nakada a447563cf8
[DOC] Added Exception.exception to Exception.new [ci skip] 2020-06-18 11:36:21 +09:00
Yusuke Endoh 35a6741816 Revert "[DOC] Added Exception.exception to Exception.new [ci skip]"
This reverts commit 957825639c.

Do not use [ci skip]!!!!
2020-06-18 09:19:43 +09:00
Nobuyoshi Nakada 957825639c
[DOC] Added Exception.exception to Exception.new [ci skip] 2020-06-18 09:00:34 +09:00
Nobuyoshi Nakada e14cba354c
[DOC] argument to Exception#excepton is optional [ci skip] 2020-06-18 08:59:47 +09:00
Nobuyoshi Nakada e384707296
Updated builtin type names
Fixnum and Bignum have been unified to Integer already.
2020-06-16 00:26:17 +09:00
Jean Boussier 385ac07fd8 Use receiver #name rather than #inspect to build NameError message 2020-05-26 14:10:33 +09:00
Yusuke Endoh 39365b46e2
Merge pull request #3047 from mame/suppress-backtrace
Add `--suppress-backtrace=num` option to limit the backtrace length
2020-05-15 01:22:56 +09:00
Jean Boussier 1258a0fb90 Remove the 65 size limit for name_err_mesg_to_str
This limit was introduced on Nov 20 1996
in 554b989ba1

Apparently to protect from a buffer overflow:

  * eval.c (f_missing): オブジェクトの文字列表現が長すぎる時バッファ
	  を書き潰していた

However I tested that path with very large strings
and it works fine.
2020-05-11 09:15:24 -07:00
卜部昌平 9e41a75255 sed -i 's|ruby/impl|ruby/internal|'
To fix build failures.
2020-05-11 09:24:08 +09:00
卜部昌平 d7f4d732c1 sed -i s|ruby/3|ruby/impl|g
This shall fix compile errors.
2020-05-11 09:24:08 +09:00
Nobuyoshi Nakada d72fd1e45b
Added rb_syserr_new_path
Similar to rb_syserr_fail_path, but just returns the created
exception instance instead of raising it.
2020-04-15 21:00:53 +09:00
卜部昌平 9e6e39c351
Merge pull request #2991 from shyouhei/ruby.h
Split ruby.h
2020-04-08 13:28:13 +09:00
Nobuyoshi Nakada aefb13eb63
Added rb_warn_deprecated_to_remove
Warn the deprecation and future removal, with obeying the warning
flag.
2020-01-23 21:42:15 +09:00
Jeremy Evans e18b817b1f Make taint warnings non-verbose instead of verbose 2020-01-22 11:19:13 -08:00
Koichi Sasada 33d866558b support RUBY_ON_BUG envval on assert failure.
Check RUBY_ON_BUG env val also on rb_assert_failure().
2020-01-06 15:06:03 +09:00
Nobuyoshi Nakada d7bef803ac Separate builtin initialization calls 2019-12-29 12:34:55 +09:00
卜部昌平 5e22f873ed decouple internal.h headers
Saves comitters' daily life by avoid #include-ing everything from
internal.h to make each file do so instead.  This would significantly
speed up incremental builds.

We take the following inclusion order in this changeset:

1.  "ruby/config.h", where _GNU_SOURCE is defined (must be the very
    first thing among everything).
2.  RUBY_EXTCONF_H if any.
3.  Standard C headers, sorted alphabetically.
4.  Other system headers, maybe guarded by #ifdef
5.  Everything else, sorted alphabetically.

Exceptions are those win32-related headers, which tend not be self-
containing (headers have inclusion order dependencies).
2019-12-26 20:45:12 +09:00
zverok d78fcfb7ab Fix FrozenError#receiver and #initialize docs 2019-12-22 23:17:39 +09:00
Nobuyoshi Nakada cc87037f1c
Fixed misspellings
Fixed misspellings reported at [Bug #16437], missed and a new
typo.
2019-12-22 22:49:17 +09:00
Nobuyoshi Nakada d76c8cfecd
RDoc of Warning.[] and .[]= [Feature #16345] [ci skip] 2019-12-22 15:18:44 +09:00
Nobuyoshi Nakada 07e595fdbd
Added `experimental` warning category
[Feature #16420]
2019-12-20 23:48:15 +09:00
Nobuyoshi Nakada a84ad24386
Added -W: command line option
To manage `Warning[category]` flags.  Only `-W:deprecated` and
`-W:no-deprecated` are available now.  [Feature #16345]
2019-12-20 23:05:22 +09:00
Nobuyoshi Nakada 435a4ca2a3
Makes the receiver to FrozenError.new a keyword parameter
[Feature #16419]
2019-12-20 14:18:20 +09:00
Nobuyoshi Nakada c6c67254fb
Added rb_warn_deprecated 2019-12-19 09:52:17 +09:00
Nobuyoshi Nakada 9bf9de3d9d
Made the warning for deprecated constants follow the category flag 2019-12-19 09:52:16 +09:00
Nobuyoshi Nakada db2ea9b0c5
[DOC] Fixed the class name in FrozenError#receiver 2019-12-15 00:21:19 +09:00
Nobuyoshi Nakada 38b9d213f1
Revert "[DOC] Fixed the class name in FrozenError#receiver"
This reverts commit 5f56a5fc9b.
`FrozenError.new(mesg, nil).receiver` should not raise an
ArgumentError.
2019-12-15 00:19:02 +09:00
Nobuyoshi Nakada 5f56a5fc9b
[DOC] Fixed the class name in FrozenError#receiver 2019-12-15 00:14:16 +09:00
Nobuyoshi Nakada 33f0ef44fd
[DOC] Fixed the FrozenError.new result [ci skip] 2019-12-15 00:14:16 +09:00
Nobuyoshi Nakada 6183addf6a Add `Warning.[]` and `Warning.[]=` 2019-12-13 20:47:07 +09:00
Nobuyoshi Nakada f3b1b645ed Create backtrace location array directly 2019-12-13 20:47:07 +09:00
Nobuyoshi Nakada 0b5268afbc Moved Kernel#warn to warning.rb 2019-12-13 20:47:07 +09:00
卜部昌平 0e8219f591 make functions static
These functions are used from within a compilation unit so we can
make them static, for better binary size.  This changeset reduces
the size of generated ruby binary from 26,590,128 bytes to
26,584,472 bytes on my macihne.
2019-11-19 12:36:19 +09:00
Jeremy Evans ffd0820ab3 Deprecate taint/trust and related methods, and make the methods no-ops
This removes the related tests, and puts the related specs behind
version guards.  This affects all code in lib, including some
libraries that may want to support older versions of Ruby.
2019-11-18 01:00:25 +02:00
Jeremy Evans c5c05460ac Warn on access/modify of $SAFE, and remove effects of modifying $SAFE
This removes the security features added by $SAFE = 1, and warns for access
or modification of $SAFE from Ruby-level, as well as warning when calling
all public C functions related to $SAFE.

This modifies some internal functions that took a safe level argument
to no longer take the argument.

rb_require_safe now warns, rb_require_string has been added as a
version that takes a VALUE and does not warn.

One public C function that still takes a safe level argument and that
this doesn't warn for is rb_eval_cmd.  We may want to consider
adding an alternative method that does not take a safe level argument,
and warn for rb_eval_cmd.
2019-11-18 01:00:25 +02:00
卜部昌平 c9ffe751d1 delete unused functions
Looking at the list of symbols inside of libruby-static.a, I found
hundreds of functions that are defined, but used from nowhere.

There can be reasons for each of them (e.g. some functions are
specific to some platform, some are useful when debugging, etc).
However it seems the functions deleted here exist for no reason.

This changeset reduces the size of ruby binary from 26,671,456
bytes to 26,592,864 bytes on my machine.
2019-11-14 20:35:48 +09:00
卜部昌平 3f413896c3 forgot to delete unused #incude line 2019-10-10 18:15:33 +09:00
卜部昌平 2d393bf125 guard rb_fatal against non-GVL call
Suggested by ko1.  rb_fatal requires GVL so just in case one lacks,
print that information and let the process die.  As commented,
we cannot print the given messages on such situations.
2019-10-10 17:49:31 +09:00
卜部昌平 f1ce4897f2 make rb_raise a GVL-only function again
Requested by ko1 that ability of calling rb_raise from anywhere
outside of GVL is "too much".  Give up that part, move the GVL
aquisition routine into gc.c, and make our new gc_raise().
2019-10-10 17:10:21 +09:00
卜部昌平 d96f04d73a add "[FATAL]" marker on abort
Indicate that the situation is fatal.
2019-10-10 17:10:21 +09:00
卜部昌平 9c3153e0da allow rb_raise from outside of GVL
Now that allocation routines like ALLOC_N() can raise exceptions
on integer overflows.  This is a problem when the calling thread
has no GVL.  Memory allocations has been allowed without it, but
can still fail.

Let's just relax rb_raise's restriction so that we can call it
with or without GVL.  With GVL the behaviour is unchanged.  With
no GVL, wait for it.

Also, integer overflows can theoretically occur during GC when
we expand the object space.  We cannot do so much then.  Call
rb_memerror and let that routine abort the process.
2019-10-10 12:07:38 +09:00
Nobuyoshi Nakada 29e6782f5d
Share ruby_sighandler_t definition 2019-10-09 23:39:58 +09:00
Yusuke Endoh 891cbd66a4 signal.c: save the original sighandlers for fatal signals
On Android, a signal handler that is not SIG_DFL is set by default for
SIGSEGV.  Ruby's install_sighandler inserts Ruby's handler only when the
signal has no handler, so it does not insert Ruby's SEGV report handler,
which caused some test failures.

This changeset forces to install Ruby's handler for some fatal signals
(sigbus, sigsegv, and sigill).  They keep the original handlers, and
call them when the interpreter receives the signals.
2019-10-09 23:22:15 +09:00
Yusuke Endoh dd477df411 error.c (rb_bug_for_fatal_signal): renamed from rb_bug_context
Just refactoring.

The name "rb_bug_context" is completely unclear for me.
(Can you see that "context" means "machine register context"?)
The context is available only when a fatal signal (sigbus, sigsegv, or
sigill) is received; in fact, the function is used only for fatal
signals.  So, I think the name should be changed.
2019-10-09 23:02:22 +09:00
Jeremy Evans 80b5a0ff2a
Make rb_scan_args handle keywords more similar to Ruby methods (#2460)
Cfuncs that use rb_scan_args with the : entry suffer similar keyword
argument separation issues that Ruby methods suffer if the cfuncs
accept optional or variable arguments.

This makes the following changes to : handling.

* Treats as **kw, prompting keyword argument separation warnings
  if called with a positional hash.

* Do not look for an option hash if empty keywords are provided.
  For backwards compatibility, treat an empty keyword splat as a empty
  mandatory positional hash argument, but emit a a warning, as this
  behavior will be removed in Ruby 3.  The argument number check
  needs to be moved lower so it can correctly handle an empty
  positional argument being added.

* If the last argument is nil and it is necessary to treat it as an option
  hash in order to make sure all arguments are processed, continue to
  treat the last argument as the option hash. Emit a warning in this case,
  as this behavior will be removed in Ruby 3.

* If splitting the keyword hash into two hashes, issue a warning, as we
  will not be splitting hashes in Ruby 3.

* If the keyword argument is required to fill a mandatory positional
  argument, continue to do so, but emit a warning as this behavior will
  be going away in Ruby 3.

* If keyword arguments are provided and the last argument is not a hash,
  that indicates something wrong. This can happen if a cfunc is calling
  rb_scan_args multiple times, and providing arguments that were not
  passed to it from Ruby.  Callers need to switch to the new
  rb_scan_args_kw function, which allows passing of whether keywords
  were provided.

This commit fixes all warnings caused by the changes above.

It switches some function calls to *_kw versions with appropriate
kw_splat flags. If delegating arguments, RB_PASS_CALLED_KEYWORDS
is used.  If creating new arguments, RB_PASS_KEYWORDS is used if
the last argument is a hash to be treated as keywords.

In open_key_args in io.c, use rb_scan_args_kw.
In this case, the arguments provided come from another C
function, not Ruby.  The last argument may or may not be a hash,
so we can't set keyword argument mode.  However, if it is a
hash, we don't want to warn when treating it as keywords.

In Ruby files, make sure to appropriately use keyword splats
or literal keywords when calling Cfuncs that now issue keyword
argument separation warnings through rb_scan_args.  Also, make
sure not to pass nil in place of an option hash.

Work around Kernel#warn warnings due to problems in the Rubygems
override of the method.  There is an open pull request to fix
these issues in Rubygems, but part of the Rubygems tests for
their override fail on ruby-head due to rb_scan_args not
recognizing empty keyword splats, which this commit fixes.

Implementation wise, adding rb_scan_args_kw is kind of a pain,
because rb_scan_args takes a variable number of arguments.
In order to not duplicate all the code, the function internals need
to be split into two functions taking a va_list, and to avoid passing
in a ton of arguments, a single struct argument is used to handle
the variables previously local to the function.
2019-09-25 11:18:49 -07:00
Jeremy Evans 00744a03d5 Update documentation for Exception [ci skip]
Mostly from burdettelamar@yahoo.com (Burdette Lamar).

Implements [Misc #16156]
2019-09-09 15:23:26 -07:00
Nobuyoshi Nakada 8b2e1ca10e
Do not clear backtrace in Exception#exception
[Bug #15558]
2019-09-02 16:47:12 +09:00
Jeremy Evans 04735c48ab Minor documentation fixes [ci skip]
From zverok (Victor Shepelev)

Fixes [Misc #16126]
2019-08-24 14:05:19 -07:00
Nobuyoshi Nakada b4daa44270
Use modifier for pid_t 2019-08-19 16:32:57 +09:00
Koichi Sasada 53a55aeff3
introduce RUBY_ON_BUG envval. (#2331)
`rb_bug()` is called at critical bug, MRI can't run anymore.
To make debug easy, this patch introduces RUBY_ON_BUG environment
variable to specify the process which is called with pid.
[Feature #16090] [GH #2331]

  RUBY_ON_BUG='gdb -p' ruby xxx.rb

In this case, if ruby interpreter causes critical bug, and call
rb_bug(), then "gdb -p [PID]' is called by system(3). You can
debug on invoked gdb.

This feature is limited on RUBY_DEVEL build.
2019-08-15 13:48:58 +09:00
Steven Harman 7da40d74e1 backtrace and backtrace_locations can be nil (#2358)
Exception#backtrace and Exception#backtrace_locations can both be nil if
not set. The former can be set via `Exception#set_backtrace`, but the
later is only ever set at runtime via `setup_backtrace`.
2019-08-14 10:35:47 -04:00
Jeremy Evans 404850e134 Remove documentation that fatal cannot be rescued [ci skip]
You can rescue it:

f = ObjectSpace.each_object(Class){|c| break c if c.name == 'fatal'}
begin
  raise f
rescue f
  2
end # => 2

It's not a good idea to rescue fatal exceptions you didn't generate
yourself, though.

Fixes [Bug #10691]
2019-08-12 09:56:35 -07:00
Nobuyoshi Nakada 4ea5c5610a
Predefine some IDs 2019-08-03 10:18:39 +09:00
git bdc8b3789a * expand tabs. 2019-06-13 18:07:19 +09:00
Luke Gruber 02b1a85385
remove 2 redundant calls to rb_str_dup
Because `rb_class_path` calls `rb_str_dup` already.

Closes: https://github.com/ruby/ruby/pull/2232
2019-06-13 18:05:04 +09:00
Nobuyoshi Nakada 1624d77f3e
error.c: avoid infinite recursion at inspecting the frozen object 2019-06-05 13:31:09 +09:00
git 7c776038ec * expand tabs. 2019-06-05 11:29:04 +09:00
Jeremy Evans f1f04caf60 Include inspect value of object in FrozenError messages
FrozenError#receiver was added recently for getting the related
object programmatically.  However, there are cases where FrozenError
is raised and not handled, and in those cases the resulting error
messages lack detail, which makes debugging the error more difficult,
especially in cases where the error is not easily reproducible.
This includes the inspect value of the frozen object in FrozenError
messages, which should make debugging simpler.
2019-06-04 19:25:03 -07:00
git 5a6c77bbe8 * expand tabs. 2019-05-27 03:10:15 +09:00
Jeremy Evans 39eadca76b Add FrozenError#receiver
Similar to NameError#receiver, this returns the object on which
the modification was attempted.  This is useful as it can pinpoint
exactly what is frozen.  In many cases when a FrozenError is
raised, you cannot determine from the context which object is
frozen that you attempted to modify.

Users of the current rb_error_frozen C function will have to switch
to using rb_error_frozen_object or the new rb_frozen_error_raise
in order to set the receiver of the FrozenError.

To allow the receiver to be set from Ruby, support an optional
second argument to FrozenError#initialize.

Implements [Feature #15751]
2019-05-26 11:09:21 -07:00
ktsj 9738f96fcf Introduce pattern matching [EXPERIMENTAL]
[ruby-core:87945] [Feature #14912]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67586 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-04-17 06:48:03 +00:00