From: "Earlopain (A S) via ruby-core" Date: 2024-08-18T08:30:58+00:00 Subject: [ruby-core:118875] [Ruby master Bug#20681] Regular expression warnings are treated as compiler warnings during runtime Issue #20681 has been updated by Earlopain (A S). nobu (Nobuyoshi Nakada) wrote in #note-1: > You may want to re-define `Warning.warn`. Thank you, that works. Apologies for the wrong report. ---------------------------------------- Bug #20681: Regular expression warnings are treated as compiler warnings during runtime https://bugs.ruby-lang.org/issues/20681#change-109447 * Author: Earlopain (A S) * Status: Feedback * ruby -v: 3.3.4 * Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN ---------------------------------------- I have some code that recieves arbitrary input and parses it as a regexp. To supress potential warnings I'm defining the `warn` method. Unfortunately it is not getting called: ```rb def warn(...) puts "CALLED" end source = "/\w**/" Regexp.new(source) ``` Running this emits a warning and doesn't print "CALLED": ``` $ ruby test.rb test.rb:6: warning: regular expression has redundant nested repeat operator '*': /\/w**\// ``` I looked a bit at the code and found something which I think is supposed to handle this case but it seems like its not checking against the right thing: https://github.com/ruby/ruby/blob/4dbf386ca248df0f47f31dc28cdeabe8d4477e5b/regparse.c#L2986-L2994 -- 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/lists/ruby-core.ml.ruby-lang.org/