aboutsummaryrefslogtreecommitdiffstats
path: root/error.c
Commit message (Collapse)AuthorAgeFilesLines
* Bypass check for warning_category on internal callsNobuyoshi Nakada2020-12-281-26/+37
|
* Make NoMatchingPatternError a subclass of StandardErrorKazuki Tsujimoto2020-12-231-1/+1
|
* Data: delete卜部昌平2020-12-221-1/+1
| | | | | | | | Has been deprecated since 684bdf6171b76f5bc5e4f05926a5ab01ec2b4fd5. 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.
* Use category: :experimental in warnings that are related to experimental ↵Jeremy Evans2020-12-181-0/+14
| | | | | | | | | 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.
* Make warning_categories a map of category symbols to category numbersJeremy Evans2020-12-181-15/+12
| | | | | | | Use this to simplify rb_warning_category_from_name. This also adds support for using the :experimental category in Kernel#warn and Warning.warn.
* Switch rb_category_warn{,ing} to accept an rb_warning_category_tJeremy Evans2020-12-181-4/+12
| | | | | | | | | | 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.
* Cache warning category IDsNobuyoshi Nakada2020-12-151-4/+8
|
* Help RDoc find Exception [ci skip]Alan Wu2020-12-141-0/+2
| | | | This was on top of `Init_Exception()`.
* Supported category option in Warning#warnNobuyoshi Nakada2020-12-081-3/+8
|
* [DOC] Fixed RDoc directives [ci skip]v3_0_0_preview2Nobuyoshi Nakada2020-12-081-2/+2
|
* Call rb_bug_without_die on CITakashi Kokubun2020-11-261-2/+10
| | | | when GC.compact's SEGV handler is installed
* Ignore <internal: entries from core library methods for Kernel#warn(message, ↵Benoit Daloze2020-10-261-2/+3
| | | | | | uplevel: n) * Fixes [Bug #17259]
* Use rb_intern_const instead of rb_intern in Init functionsNobuyoshi Nakada2020-10-211-1/+1
| | | | | | | | | ``` find . -name \*.o -exec nm {} + |& sed '/Init_.*\.rbimpl_id/!d;s/^.* b //;s/\.[1-9][0-9]*$//;s/\.rbimpl_id$//' | uniq ``` should be empty.
* Update example to handle keywords passed to Warning.warnBenoit Daloze2020-10-031-2/+2
|
* Improve docs of the Warning moduleBenoit Daloze2020-10-021-5/+26
|
* Add rb_category_warn{,ing} for warning messages with categoriesJeremy Evans2020-09-281-23/+63
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Make Warning.warn accept only category keywordJeremy Evans2020-09-281-2/+7
| | | | | | | 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.
* Disable deprecation warning by the default [Feature #16345]Nobuyoshi Nakada2020-09-251-1/+3
| | | | And `-w` option turns it on.
* Fix `warning: instance variable bt_locations not initialized`Kazuhiro NISHIYAMA2020-09-151-1/+1
|
* Fix missing `"` [ci skip]Kazuhiro NISHIYAMA2020-09-151-1/+1
|
* Make it possible to dump and load an exception objectYusuke Endoh2020-09-061-0/+46
| | | | | | | | | | | | | | | | | | | | | 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
* Hoisted out warn_deprecatedNobuyoshi Nakada2020-09-031-25/+14
|
* Add category to `rb_warn_deprecated`eileencodes2020-09-021-2/+17
| | | | | | | | | | | | | | | 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
* Support passing a category to `Warning.warn`eileencodes2020-09-011-5/+25
| | | | | | | | | | | | | | | | | | | | | | 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>
* add UNREACHABLE_RETURN卜部昌平2020-06-291-0/+1
| | | | | | 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.
* builtin_class_name: add variant that return VALUE卜部昌平2020-06-291-13/+18
| | | | | Found that `if (builtin_class_name) { printf } else { printf }` happens twice. It would be better if we could eliminate those if statements.
* rb_check_typeddata: do not goto into a branch卜部昌平2020-06-291-14/+14
| | | | | I'm not necessarily against every goto in general, but jumping into a branch is definitely a bad idea. Better refactor.
* [DOC] Added Exception.exception to Exception.new [ci skip]Nobuyoshi Nakada2020-06-181-1/+2
|
* Revert "[DOC] Added Exception.exception to Exception.new [ci skip]"Yusuke Endoh2020-06-181-3/+2
| | | | | | This reverts commit 957825639c1422777c09578d4a03adf571eac55d. Do not use [ci skip]!!!!
* [DOC] Added Exception.exception to Exception.new [ci skip]Nobuyoshi Nakada2020-06-181-2/+3
|
* [DOC] argument to Exception#excepton is optional [ci skip]Nobuyoshi Nakada2020-06-181-1/+1
|
* Updated builtin type namesNobuyoshi Nakada2020-06-161-2/+2
| | | | Fixnum and Bignum have been unified to Integer already.
* Use receiver #name rather than #inspect to build NameError messageJean Boussier2020-05-261-1/+14
|
* Merge pull request #3047 from mame/suppress-backtraceYusuke Endoh2020-05-151-0/+1
| | | Add `--suppress-backtrace=num` option to limit the backtrace length
* Remove the 65 size limit for name_err_mesg_to_strJean Boussier2020-05-111-1/+1
| | | | | | | | | | | | | This limit was introduced on Nov 20 1996 in 554b989ba1623b9f6a0b76f00824c83a23fbcbc1 Apparently to protect from a buffer overflow: * eval.c (f_missing): オブジェクトの文字列表現が長すぎる時バッファ を書き潰していた However I tested that path with very large strings and it works fine.
* sed -i 's|ruby/impl|ruby/internal|'卜部昌平2020-05-111-1/+1
| | | | To fix build failures.
* sed -i s|ruby/3|ruby/impl|g卜部昌平2020-05-111-1/+1
| | | | This shall fix compile errors.
* Added rb_syserr_new_pathNobuyoshi Nakada2020-04-151-1/+7
| | | | | Similar to rb_syserr_fail_path, but just returns the created exception instance instead of raising it.
* Merge pull request #2991 from shyouhei/ruby.h卜部昌平2020-04-081-1/+1
| | | Split ruby.h
* Added rb_warn_deprecated_to_removeNobuyoshi Nakada2020-01-231-2/+16
| | | | | Warn the deprecation and future removal, with obeying the warning flag.
* Make taint warnings non-verbose instead of verboseJeremy Evans2020-01-221-2/+2
|
* support RUBY_ON_BUG envval on assert failure.Koichi Sasada2020-01-061-11/+0
| | | | Check RUBY_ON_BUG env val also on rb_assert_failure().
* Separate builtin initialization callsNobuyoshi Nakada2019-12-291-6/+0
|
* decouple internal.h headers卜部昌平2019-12-261-10/+23
| | | | | | | | | | | | | | | | | | 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).
* Fix FrozenError#receiver and #initialize docszverok2019-12-221-1/+2
|
* Fixed misspellingsNobuyoshi Nakada2019-12-221-1/+1
| | | | | Fixed misspellings reported at [Bug #16437], missed and a new typo.
* RDoc of Warning.[] and .[]= [Feature #16345] [ci skip]Nobuyoshi Nakada2019-12-221-0/+25
|
* Added `experimental` warning categoryNobuyoshi Nakada2019-12-201-0/+3
| | | | [Feature #16420]
* Added -W: command line optionNobuyoshi Nakada2019-12-201-0/+7
| | | | | To manage `Warning[category]` flags. Only `-W:deprecated` and `-W:no-deprecated` are available now. [Feature #16345]
* Makes the receiver to FrozenError.new a keyword parameterNobuyoshi Nakada2019-12-201-8/+15
| | | | [Feature #16419]