summaryrefslogtreecommitdiff
path: root/error.c
AgeCommit message (Collapse)Author
2025-12-10Use actual class instead of singleton class in frozen error messageJeremy Evans
With the following code: ```ruby object = [] object.singleton_class object.freeze object.instance_variable_set(:@a, 42) ``` The previous error message was: ``` can't modify frozen #<Class:#<Array:0x00000631d1308f78>>: [] ``` With this change, the error message is: ``` can't modify frozen Array: [] ``` Since we show the inspect value of the affected object, I think including the singleton class instead of the actual class if it exists makes the error message harder to understand.
2025-11-19Win32: Allow some mingw implemeations to use old msvcrtNobuyoshi Nakada
2025-11-19Win32: Drop support for older than MSVC 8.0/_MSC_VER 1400Nobuyoshi Nakada
Visual C++ 2005 (8.0): - _MSC_VER: 1400 - MSVCRT_VERSION: 80
2025-10-13[DOC] Fix typosÉtienne Barrié
Inspired by 42ba82424d908c290a4a34ced8853f0a403b734b, I looked for other occurrences of "the the".
2025-10-08[Bug #21629] Initialize `struct RString`Nobuyoshi Nakada
2025-09-24rb_bug shouldn't assume ec is available (don't use GET_EC())Luke Gruber
ec is unavailable on timer thread, for instance.
2025-08-07Convert `name_err_mesg` to use `rb_gc_mark_and_move`Jean Boussier
The `p->field = rb_gc_location(p->field)` isn't ideal because it means all references are rewritten on compaction, regardless of whether the referenced object has moved. This isn't good for caches nor for Copy-on-Write. `rb_gc_mark_and_move` avoid needless writes, and most of the time allow to have a single function for both marking and updating references.
2025-08-05Fix typo in documentation comment for exc_inspect method in error.cydah
2025-08-04[DOC] Fill undocumented documentsNobuyoshi Nakada
2025-04-19Fix style [ci skip]Nobuyoshi Nakada
2025-01-31[DOC] Improve Errno and SystemCallError.newNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/12683
2025-01-02[DOC] Exclude 'Class' and 'Module' from RDoc's autolinkingNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/12496
2024-12-24[DOC] Adjust documentation related to backtraces (#12420)Victor Shepelev
Notes: Merged-By: zverok <zverok.offline@gmail.com>
2024-12-22Fix extra 'warning:' prefix for chilled Symbol#to_szverok
Notes: Merged: https://github.com/ruby/ruby/pull/12423
2024-12-19[DOC] Link to special `fatal` class through `rdoc-ref`Stan Lo
Notes: Merged: https://github.com/ruby/ruby/pull/12391
2024-12-15Suppress -Wsuggest-attribute=formatTakashi Kokubun
2024-12-12Fix LoadError's linking issueStan Lo
Original issue: https://github.com/ruby/rdoc/issues/1128 The problem is caused by the `# :stopdoc:` directive in `bundled_gems.rb`, which's scope covers the redefinition of `LoadError`. Since the goal of `# :stopdoc:` is to hide the documentation of `Gem::BUNDLED_GEMS`, we can use `# :nodoc:` on it instead. Notes: Merged: https://github.com/ruby/ruby/pull/12317
2024-12-12Implement rb_bug_without_diePeter Zhu
Notes: Merged: https://github.com/ruby/ruby/pull/12309
2024-12-12Add `rb_warn_reserved_name_at`Nobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/12315
2024-11-27Make rb_bug_without_die staticPeter Zhu
It's not used outside of error.c. Notes: Merged: https://github.com/ruby/ruby/pull/12183
2024-11-25error.c: call `va_end` before jumpingJean Boussier
The man page is clear that every `va_start` call MUST be succeeded by the corresponding `va_end` call. So `rb_raise` can't call `rb_exc_raise` before `va_end`, otherwise `va_end` is never called. Co-Authored-By: Étienne Barrié <etienne.barrie@gmail.com>
2024-11-13Mark strings returned by Symbol#to_s as chilled (#12065)Jean byroot Boussier
* Use FL_USER0 for ELTS_SHARED This makes space in RString for two bits for chilled strings. * Mark strings returned by `Symbol#to_s` as chilled [Feature #20350] `STR_CHILLED` now spans on two user flags. If one bit is set it marks a chilled string literal, if it's the other it marks a `Symbol#to_s` chilled string. Since it's not possible, and doesn't make much sense to include debug info when `--debug-frozen-string-literal` is set, we can't include allocation source, but we can safely include the symbol name in the warning message, making it much easier to find the source of the issue. Co-Authored-By: Étienne Barrié <etienne.barrie@gmail.com> --------- Co-authored-by: Étienne Barrié <etienne.barrie@gmail.com> Co-authored-by: Jean Boussier <jean.boussier@gmail.com>
2024-11-07Respect RUBY_CRASH_REPORT path when RUBY_ASSERT() failsAlan Wu
Previously, it always used stderr. Slight shuffle of the first line of the crash due to reusing code from rb_bug(): ```diff -Assertion Failed: /ruby/object.c:649:rb_obj_itself:false +/ruby/object.c:649: Assertion Failed: rb_obj_itself:false ``` Tested locally to confirm that it writes to the file given with RUBY_CRASH_REPORT. Follow-up for [Feature #19790]. Notes: Merged: https://github.com/ruby/ruby/pull/12019 Merged-By: XrXr
2024-11-06`Warning[:strict_unused_block]`Koichi Sasada
to show unused block warning strictly. ```ruby class C def f = nil end class D def f = yield end [C.new, D.new].each{|obj| obj.f{}} ``` In this case, `D#f` accepts a block. However `C#f` doesn't accept a block. There are some cases passing a block with `obj.f{}` where `obj` is `C` or `D`. To avoid warnings on such cases, "unused block warning" will be warned only if there is not same name which accepts a block. On the above example, `C.new.f{}` doesn't show any warnings because there is a same name `D#f` which accepts a block. We call this default behavior as "relax mode". `strict_unused_block` new warning category changes from "relax mode" to "strict mode", we don't check same name methods and `C.new.f{}` will be warned. [Feature #15554] Notes: Merged: https://github.com/ruby/ruby/pull/12005
2024-10-21Show where mutated chilled strings were allocatedÉtienne Barrié
[Feature #20205] The warning now suggests running with --debug-frozen-string-literal: ``` test.rb:3: warning: literal string will be frozen in the future (run with --debug-frozen-string-literal for more information) ``` When using --debug-frozen-string-literal, the location where the string was created is shown: ``` test.rb:3: warning: literal string will be frozen in the future test.rb:1: info: the string was created here ``` When resurrecting strings and debug mode is not enabled, the overhead is a simple FL_TEST_RAW. When mutating chilled strings and deprecation warnings are not enabled, the overhead is a simple warning category enabled check. Co-authored-by: Jean Boussier <byroot@ruby-lang.org> Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org> Co-authored-by: Jean Boussier <byroot@ruby-lang.org> Notes: Merged: https://github.com/ruby/ruby/pull/11893
2024-10-09Fix spellingJohn Bampton
Notes: Merged: https://github.com/ruby/ruby/pull/11835
2024-09-27[DOC] Improve description of `LoadError#path` and `SyntaxError#path`David Rodríguez
Notes: Merged: https://github.com/ruby/ruby/pull/11684 Merged-By: nobu <nobu@ruby-lang.org>
2024-09-25doc: Remove description of experimental warnings related pattern matching ↵masatoshi_moritsuka
from documentation Ruby 3.2.0 has been released and all experimental warnings about pattern matching have been removed. Experimental warnings about pattern matching are no longer output, so I remove description about it from documentation as well. cf. https://bugs.ruby-lang.org/issues/18585 cf. db6b23c76cbc7888cd9a9912790c2068703afdd0 cf. https://twitter.com/k_tsj/status/1606956336037900289?s=20&t=-_PSYLhYPtYsB9FZhtXl5A Notes: Merged: https://github.com/ruby/ruby/pull/7052
2024-07-19Make rb_check_frozen_inline() static inline againAlan Wu
Since 730e3b2ce01915c4a98b79bb281b2c38a9ff1131 ("Stop exposing `rb_str_chilled_p`"), we noticed a speed loss on a few benchmarks that are string operations heavy. This is partially due to routines no longer having the options to inline rb_check_frozen_inline() in non-LTO builds. Make it an inlining candidate again to recover speed. Testing this patch on my machine, the fannkuchredux benchmark gets a 1.15 speed-up with YJIT and 1.03 without YJIT. Notes: Merged: https://github.com/ruby/ruby/pull/11211
2024-06-26[DOC] Doc for exceptions (#11008)Burdette Lamar
2024-06-25Show the detail info in the first lineNobuyoshi Nakada
2024-06-11Don't call `Warning.warn` unless the category is enabledAaron Patterson
The warning category should be enabled if we want to call `Warning.warn`. This commit speeds up the following benchmark: ```ruby eval "def test; " + 1000.times.map { "' '.chomp!" }.join(";") + "; end" def run_benchmark count i = 0 while i < count start = Process.clock_gettime(Process::CLOCK_MONOTONIC) yield ms = Process.clock_gettime(Process::CLOCK_MONOTONIC) - start puts "itr ##{i}: #{(ms * 1000).to_i}ms" i += 1 end end run_benchmark(25) do 250.times do test end end ``` On `master` this runs at about 92ms per iteration. With this patch, it is 7ms per iteration. [Bug #20573]
2024-06-05[DOC] Doc for module Errno (#10913)Burdette Lamar
2024-06-02Stop exposing `rb_str_chilled_p`Jean Boussier
[Feature #20205] Now that chilled strings no longer appear as frozen, there is no need to offer an API to check for chilled strings. We however need to change `rb_check_frozen_internal` to no longer be a macro, as it needs to check for chilled strings.
2024-05-30[DEBUG] More info when SyntaxError#path changedNobuyoshi Nakada
2024-05-28Stop marking chilled strings as frozenÉtienne Barrié
They were initially made frozen to avoid false positives for cases such as: str = str.dup if str.frozen? But this may cause bugs and is generally confusing for users. [Feature #20205] Co-authored-by: Jean Boussier <byroot@ruby-lang.org>
2024-05-26Debug unexpectedly changed pathNobuyoshi Nakada
2024-05-08[PRISM] Use correct warning encodingKevin Newton
2024-03-19Implement chilled stringsÉtienne Barrié
[Feature #20205] As a path toward enabling frozen string literals by default in the future, this commit introduce "chilled strings". From a user perspective chilled strings pretend to be frozen, but on the first attempt to mutate them, they lose their frozen status and emit a warning rather than to raise a `FrozenError`. Implementation wise, `rb_compile_option_struct.frozen_string_literal` is no longer a boolean but a tri-state of `enabled/disabled/unset`. When code is compiled with frozen string literals neither explictly enabled or disabled, string literals are compiled with a new `putchilledstring` instruction. This instruction is identical to `putstring` except it marks the String with the `STR_CHILLED (FL_USER3)` and `FL_FREEZE` flags. Chilled strings have the `FL_FREEZE` flag as to minimize the need to check for chilled strings across the codebase, and to improve compatibility with C extensions. Notes: - `String#freeze`: clears the chilled flag. - `String#-@`: acts as if the string was mutable. - `String#+@`: acts as if the string was mutable. - `String#clone`: copies the chilled flag. Co-authored-by: Jean Boussier <byroot@ruby-lang.org>
2024-03-18Update set_backtrace documentationJean Boussier
Followup: https://github.com/ruby/ruby/pull/10017 [Feature #13557]
2024-03-14`Exception#set_backtrace` accept arrays of `Backtrace::Location`Jean Boussier
[Feature #13557] Setting the backtrace with an array of strings is lossy. The resulting exception will return nil on `#backtrace_locations`. By accepting an array of `Backtrace::Location` instance, we can rebuild a `Backtrace` instance and have a fully functioning Exception. Co-Authored-By: Étienne Barrié <etienne.barrie@gmail.com>
2024-03-14[Feature #20293] Add `Warning.categories`Nobuyoshi Nakada
2024-03-06Move FL_SINGLETON to FL_USER1Jean Boussier
This frees FL_USER0 on both T_MODULE and T_CLASS. Note: prior to this, FL_SINGLETON was never set on T_MODULE, so checking for `FL_SINGLETON` without first checking that `FL_TYPE` was `T_CLASS` was valid. That's no longer the case.
2024-02-23YJIT: Lazily push a frame for specialized C funcs (#10080)Takashi Kokubun
* YJIT: Lazily push a frame for specialized C funcs Co-authored-by: Maxime Chevalier-Boisvert <maxime.chevalierboisvert@shopify.com> * Fix a comment on pc_to_cfunc * Rename rb_yjit_check_pc to rb_yjit_lazy_push_frame * Rename it to jit_prepare_lazy_frame_call * Fix a typo * Optimize String#getbyte as well * Optimize String#byteslice as well --------- Co-authored-by: Maxime Chevalier-Boisvert <maxime.chevalierboisvert@shopify.com>
2024-02-08Optional detail info at assertion failureNobuyoshi Nakada
2024-01-13Fix typoNobuyoshi Nakada
2024-01-13[DOC] Documentize known_errorsNobuyoshi Nakada
2024-01-12[DOC] Mark up the class name `fatal`Nobuyoshi Nakada
2024-01-02Fix Exception#detailed_message for GC compactionPeter Zhu
Before this commit, the test fails with RGENGC_CHECK_MODE enabled: TestException#test_detailed_message_under_gc_compact_stress [test/ruby/test_exception.rb:1466]: <"\e[1mfoo (\e[1;4mRuntimeError\e[m\e[1m)\e[m\n" + "\e[1mbar\e[m\n" + "\e[1mbaz\e[m"> expected but was <"\e[1mfoo (\e[1;4mRuntimeError\e[m\e[1m)\e[m\n" + "\e[1m\x00\x00\x00\x00\x00\x00\x00\e[m">.
2023-12-21[DOC] Fix NoMethodError example of rendering (#9309)Victor Shepelev
Fix NoMethodError example of rendering