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

595 Коммитов

Автор SHA1 Сообщение Дата
Nobuyoshi Nakada e3385f8783
[Bug #19635] Preserve `errno`
The following functions are turned into macros and no longer can be
used as expressions in core.
- rb_sys_fail
- rb_sys_fail_str
- rb_sys_fail_path
2023-05-12 18:36:01 +09:00
Jean Boussier 6a5c355e4e Add RB_WARN_CATEGORY_DEFAULT_BITS
Followup: ac123f167a

RB_WARN_CATEGORY_ALL_BITS is exposed in a public header, so it
makes sense for it to be updated to contain all valid bits.

Instead we introduce RB_WARN_CATEGORY_DEFAULT_BITS to list the
categories that are enabled by default.
2023-04-14 09:46:10 +02:00
Jean Boussier ac123f167a Emit a performance warning when a class reached max variations
[Feature #19538]

This new `peformance` warning category is disabled by default.
It needs to be specifically enabled via `-W:performance` or `Warning[:performance] = true`
2023-04-13 16:36:17 +02:00
Nobuyoshi Nakada de023b68aa Disable all warning categories other than `RB_WARN_CATEGORY_ALL_BITS` 2023-04-13 18:08:08 +09:00
Takashi Kokubun 233ddfac54 Stop exporting symbols for MJIT 2023-03-06 21:59:23 -08:00
Nobuyoshi Nakada b326a5f3dd
Adjust indent [ci skip] 2023-02-20 10:50:49 +09:00
Yusuke Endoh 7d5794bad5 error.c: Use "undefined local variable or method `...' for main"
... for the toplevel.
2023-02-20 10:33:06 +09:00
Yusuke Endoh 1fd181b453 error.c: Update the message format for NoMethodError
* If the receiver is a Class, use "... for class <class name>".
* If the receiver is a Module, use "... for module <module name>".
* If the receiver is an extended object (i.e., has a singleton class),
  use "... for <rb_any_to_s(receiver)>".
* Otherwise, use "... for an instance of <class name>".

Examples:

```
42.time    #=> undefined method `time' for an instance of Integer (NoMethodError)

class Foo
  privatee #=> undefined local variable or method 'privatee' for class Foo (NoMethodError)
end

def (o=Object.new).foo
end
o.bar      #=> undefined method `bar' for #<Object: 0xdeadbeef(any_to_s)> (NoMethodError)
```
2023-02-20 10:33:06 +09:00
Yusuke Endoh e7b8d32e16 Stop using receiver#inspect for "undefined method" errors
```
42.time    #=> undefined method `time' for object Integer (NoMethodError)

class Foo
  privatee #=> undefined local variable or method 'privatee' for class Foo (NoMethodError)
end

s = ""
def s.foo = nil
s.bar      #=> undefined method `bar' for extended object String (NoMethodError)
```

[Feature #18285]
2023-02-20 10:33:06 +09:00
zverok 91076b2c59 Docs: Fix rendering of SyntaxError#path 2022-12-23 18:09:49 +02:00
Nobuyoshi Nakada 2e7e153a2a [Bug #19242] Prohibit circular causes to be loaded 2022-12-20 14:12:38 +09:00
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