From 835fa98a62ca10f06861dc7bde9cd1a5bc0d1612 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Tue, 20 Feb 2024 23:03:13 +0900 Subject: [PATCH] Update warning flags before dump --- ruby.c | 4 ++-- test/ruby/test_rubyoptions.rb | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/ruby.c b/ruby.c index 3d8823c0f3..335935a5d8 100644 --- a/ruby.c +++ b/ruby.c @@ -1739,6 +1739,8 @@ Init_extra_exts(void) static void ruby_opt_init(ruby_cmdline_options_t *opt) { + rb_warning_category_update(opt->warn.mask, opt->warn.set); + if (opt->dump & dump_exit_bits) return; if (FEATURE_SET_P(opt->features, gems)) { @@ -1754,8 +1756,6 @@ ruby_opt_init(ruby_cmdline_options_t *opt) } } - rb_warning_category_update(opt->warn.mask, opt->warn.set); - /* [Feature #19785] Warning for removed GC environment variable. * Remove this in Ruby 3.4. */ if (getenv("RUBY_GC_HEAP_INIT_SLOTS")) { diff --git a/test/ruby/test_rubyoptions.rb b/test/ruby/test_rubyoptions.rb index 6bf94fed32..856593f9f6 100644 --- a/test/ruby/test_rubyoptions.rb +++ b/test/ruby/test_rubyoptions.rb @@ -296,6 +296,8 @@ class TestRubyOptions < Test::Unit::TestCase warning = /compiler based on the Prism parser is currently experimental/ assert_in_out_err(%w(--parser=prism -e) + ["puts :hi"], "", %w(hi), warning) + assert_in_out_err(%w(--parser=prism -W:no-experimental -e) + ["puts :hi"], "", %w(hi), []) + assert_in_out_err(%w(--parser=prism -W:no-experimental --dump=parsetree -e :hi), "", /"hi"/, []) assert_in_out_err(%w(--parser=parse.y -e) + ["puts :hi"], "", %w(hi), []) assert_norun_with_rflag('--parser=parse.y', '--version', "")