diff --git a/parse.y b/parse.y index eef742c9b6..4d9ca70104 100644 --- a/parse.y +++ b/parse.y @@ -7926,7 +7926,7 @@ parser_get_bool(struct parser_params *p, const char *name, const char *val) } break; } - rb_compile_warning(p->ruby_sourcefile, p->ruby_sourceline, "invalid value for %s: %s", name, val); + rb_warning2("invalid value for %s: %s", WARN_S(name), WARN_S(val)); return -1; } diff --git a/test/ripper/test_parser_events.rb b/test/ripper/test_parser_events.rb index 4e1d233851..771434ff82 100644 --- a/test/ripper/test_parser_events.rb +++ b/test/ripper/test_parser_events.rb @@ -1588,6 +1588,12 @@ class TestRipper::ParserEvents < Test::Unit::TestCase assert_equal("frozen_string_literal", args[0]) end + def test_warning_invalid_magic_comment + fmt, *args = warning("#-*- frozen-string-literal: nottrue -*-") + assert_match(/invalid value/, fmt) + assert_equal(%w"frozen_string_literal nottrue", args) + end + def test_warn_cr_in_middle fmt = nil assert_warn("") {fmt, = warn("\r;")}