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

584 Коммитов

Автор SHA1 Сообщение Дата
Samuel Williams 6fd5d2dc00
Introduce `IO.new(..., path:)` and promote `File#path` to `IO#path`. (#6867) 2022-12-08 18:19:53 +13:00
S-H-GAMELINKS 040e0c8d67 Reuse NIL_OR_UNDEF_P macro 2022-12-02 01:19:55 +09:00
Nobuyoshi Nakada 4e68b59431 [Feature #19138] Add `SyntaxError#path` 2022-12-01 17:05:41 +09:00
S-H-GAMELINKS 1f4f6c9832 Using UNDEF_P macro 2022-11-16 18:58:33 +09:00
Sergey Fedorov 567725ed30
Fix and improve coroutines for Darwin (macOS) ppc/ppc64. (#5975) 2022-10-19 23:49:45 +13:00
Nobuyoshi Nakada f08fcd0e80
Fix possible use of undefined macros on very old macOS [ci skip] 2022-10-17 18:36:08 +09:00
S.H f1c89c8147
Reuse `with_warning_string_from` macro 2022-10-10 13:52:25 +09:00
Nobuyoshi Nakada e294e6f417
Split `with_warning_string_from` for the last named parameter 2022-09-30 17:29:23 +09:00
Yusuke Endoh a78c733cc3 Revert "Revert "error.c: Let Exception#inspect inspect its message""
This reverts commit b9f030954a.

[Bug #18170]
2022-09-23 16:40:59 +09:00
卜部昌平 104069e75a syserr_initialize: delete redundant strerror() declaration
This line issues a warning on clang.  strerror is of course a part of
ISO C since its dawn.  We practically have never needed it.
2022-09-21 11:44:09 +09:00
S-H-GAMELINKS 77fdb3a47d Introduce with_warn_vsprintf macro 2022-08-12 16:59:30 +09:00
Takashi Kokubun 5b21e94beb Expand tabs [ci skip]
[Misc #18891]
2022-07-21 09:42:04 -07:00
Yusuke Endoh c4e2973733 Fix a typo (thanks @Maumagnaguagno !) 2022-07-13 16:09:11 +09:00
Yusuke Endoh 1fe6c92603 Specify usable escape sequences in Exception#detailed_message
An error message is primarily rendered in a terminal emulator, but is
also shown in a browser by converting it to a HTML fragment.
However, the conversion would be unreasonably difficult if the message
includes any escape sequence (such as cursor move or screen clear).

This change adds a guideline about escape sequences in
`Exception#detailed_message`:

* Use widely-supported escape sequences: bold, underline, and basic
  eight foreground colors (except white and black).
* Make the message readable if all escape sequences are ignored.
2022-07-13 16:09:11 +09:00
Chris Seaton 31b2cd38c5 Include JIT information in crash reports
Since enabling YJIT or MJIT drastically changes what could go wrong at
runtime, it's good to be front and center about whether they are enabled
when dumping a crash report. Previously, `RUBY_DESCRIPTION` and the
description printed when crashing can be different when a JIT is on.

Introduce a new internal data global, `rb_dynamic_description`, and set
it to be the same as `RUBY_DESCRIPTION` during initialization; use it
when crashing.

 * version.c: Init_ruby_description(): Initialize and use
       `rb_dynamic_description`.
 * error.c: Change crash reports to use `rb_dynamic_description`.
 * ruby.c: Call `Init_ruby_description()` earlier. Slightly more work
       for when we exit right after printing the description but that
       was deemed acceptable.
 * include/ruby/version.h: Talk about how JIT info is not in
      `ruby_description`.
 * test/-ext-/bug_reporter/test_bug_reporter.rb: Remove handling for
       crash description being different from `RUBY_DESCRIPTION`.
 * test/ruby/test_rubyoptions.rb: ditto

Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
Co-authored-by: Alan Wu <alanwu@ruby-lang.org>
2022-06-20 17:18:29 -04:00
Nobuyoshi Nakada a58611dfb1 Allow to just warn as bool expected, without an exception 2022-06-20 19:35:12 +09:00
Nobuyoshi Nakada ccfbcc7302
[DOC] RDoc now accepts other than magic numbers at `rb_attr` 2022-06-08 11:55:21 +09:00
Yusuke Endoh b9f030954a Revert "error.c: Let Exception#inspect inspect its message"
This reverts commit 9d927204e7.
2022-06-07 11:52:44 +09:00
Yusuke Endoh 9d927204e7 error.c: Let Exception#inspect inspect its message
... only when the message string has a newline.

`p StandardError.new("foo\nbar")` now prints `#<StandardError: "foo\nbar">'
instead of:

    #<StandardError:
    bar>

[Bug #18170]
2022-06-07 11:07:09 +09:00
Nobuyoshi Nakada ed2dd17294
Use RBOOL 2022-06-05 14:21:01 +09:00
Nobuyoshi Nakada 7e52533104
No fallback to default values 2022-05-21 22:58:45 +09:00
Yusuke Endoh 25b0577c92 Factor a "highlight" symbol out 2022-02-22 11:55:40 +09:00
Yusuke Endoh 4db986431a Let Exception#full_message pass highlight keywords to #detailed_message
.. even when the argument is not explicitly passed.
2022-02-22 11:55:40 +09:00
Yusuke Endoh 98ca99cdd0 The default highlight arguments of Exception#detailed_message is false 2022-02-22 11:55:40 +09:00
Yusuke Endoh 35ff545bb6 Exception#detailed_message is added
Also, the default error printer and Exception#full_message use the
method instead of `Exception#message` to get the message string.

`Exception#detailed_message` calls `Exception#message`, decorates and
returns the result. It adds some escape sequences to highlight, and the
class name of the exception to the end of the first line of the message.

[Feature #18370]
2022-02-22 11:55:40 +09:00
Yusuke Endoh 36e31b09cd error.c: Refactoring
Factor out from rb_error_write the responsibility to check if stderr is
a tty.
2022-02-22 11:55:40 +09:00
Jeremy Evans 9e0a91d064 Don't segfault if Warning.warn is undefined
Check that there is a method entry for the method before passing
it to rb_method_entry_arity.

Fixes [Bug #18458]
2022-01-04 10:03:18 -08:00
Nobuyoshi Nakada 39bc5de833
Remove tainted and trusted features
Already these had been announced to be removed in 3.2.
2021-12-26 23:28:54 +09:00
S.H 75aae66c4f
Some codes replace to `RBOOL` macro (#5023)
* Some code replace and using RBOOL macro

* Fix indent

* Using RBOOL in syserr_eqq function
2021-11-09 17:09:29 +09:00
S.H a46c220320
Add `rb_mod_exc_raise` function and replace duplicate code 2021-10-30 19:24:41 +09:00
S.H dc9112cf10
Using NIL_P macro instead of `== Qnil` 2021-10-03 22:34:45 +09:00
S.H b8c3a84bdd
Refactor and Using RBOOL macro 2021-09-15 08:11:05 +09:00
卜部昌平 dddc618d30 suppress GCC's -Wsuggest-attribute=format
I was not aware of this because I use clang these days.
2021-09-10 20:00:06 +09:00
卜部昌平 1b6245ccdc include/ruby/internal/error.h: add doxygen
Must not be a bad idea to improve documents.
2021-09-10 20:00:06 +09:00
Kazuki Tsujimoto 4568ba0711
Show verbose error messages when single pattern match fails
[0] => [0, *, a]
    #=> [0] length mismatch (given 1, expected 2+) (NoMatchingPatternError)

Ignore test failures of typeprof caused by this change for now.
2021-08-15 09:38:24 +09:00
Nobuyoshi Nakada 97efd48fb1
Get rid of unintented recursion when RUBY_DEBUG 2021-08-14 23:12:31 +09:00
Nobuyoshi Nakada 1bd021a789 Mark internal class names 2021-08-14 23:11:58 +09:00
Nobuyoshi Nakada 58d82eacef Add some "cold" marks 2021-08-14 23:11:58 +09:00
Nobuyoshi Nakada edd27e120e A comment for typed data in `rb_check_type` [ci skip] 2021-08-14 23:11:58 +09:00
S.H 378e8cdad6
Using RBOOL macro 2021-08-02 12:06:44 +09:00
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