From: "Eregon (Benoit Daloze) via ruby-core" Date: 2024-04-25T17:35:20+00:00 Subject: [ruby-core:117710] [Ruby master Bug#20455] rb_errinfo() inconsistent with $! in the caller Ruby code Issue #20455 has been reported by Eregon (Benoit Daloze). ---------------------------------------- Bug #20455: rb_errinfo() inconsistent with $! in the caller Ruby code https://bugs.ruby-lang.org/issues/20455 * Author: Eregon (Benoit Daloze) * Status: Open * ruby -v: ruby 3.4.0dev (2024-04-25T08:12:47Z master 64bd8e41df) [x86_64-linux] * Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN ---------------------------------------- This (slightly modified for clarity) test in ruby/spec demonstrates the unexpected result: ```ruby describe "rb_errinfo" do def err $! end it "is cleared when entering a C method" do begin raise StandardError rescue $!.class.should == StandardError err.class.should == StandardError @s.rb_errinfo().should == nil end end ``` Why does `rb_errinfo()` return nil there, when $! is set in the caller (and $! isn't per frame but per thread, as shown with `err`)? Is this bug? If not, what is the logic and reason for clearing `$!` when calling a method defined in C? -- https://bugs.ruby-lang.org/ ______________________________________________ ruby-core mailing list -- ruby-core@ml.ruby-lang.org To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/