ruby-changes:63505
From: Nobuyoshi <ko1@a...>
Date: Mon, 2 Nov 2020 22:56:43 +0900 (JST)
Subject: [ruby-changes:63505] 79b242260b (master): ripper: Invalid pragma value warning
https://git.ruby-lang.org/ruby.git/commit/?id=79b242260b From 79b242260bc0530503dde85eda8e79b1c2aa9a6e Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Mon, 2 Nov 2020 22:48:28 +0900 Subject: ripper: Invalid pragma value warning diff --git a/parse.y b/parse.y index eef742c..4d9ca70 100644 --- a/parse.y +++ b/parse.y @@ -7926,7 +7926,7 @@ parser_get_bool(struct parser_params *p, const char *name, const char *val) https://github.com/ruby/ruby/blob/trunk/parse.y#L7926 } 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 4e1d233..771434f 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 https://github.com/ruby/ruby/blob/trunk/test/ripper/test_parser_events.rb#L1588 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;")} -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/