From: "NARUSE, Yui" Date: 2008-10-13T17:14:03+09:00 Subject: [ruby-dev:36711] Re: source file name of 'mismatched indentations' warning in ruby 1.9 成瀬です。 On Mon, 13 Oct 2008 16:27:22 +0900, masayoshi takahashi wrote: > 高橋征義です。 > > Ruby 1.9にはインデントレベルの整合性を調べて警告を吐くように > なっているようですが、requireでスクリプトを読み込む際、読み込まれる > 対象のファイルのインデントがおかしい場合でも、読み込みを行う側の > スクリプトのファイル名しか表示されません。 > > $ ./bin/ruby -w test0.rb > test0.rb:1: warning: mismatched indentations: line 1:'class' and line > 2:'end' > $ cat test0.rb > require 'test' > $ cat test.rb > class Foo > end > > 例えば上記のような場合、test.rbの名前も表示されてほしいのですが、 > それは難しい(or するべきではない)のでしょうか? > > 高橋征義 (takahashimm@gmail.com) Index: parse.y =================================================================== --- parse.y (revision 19769) +++ parse.y (working copy) @@ -4856,7 +4856,8 @@ token_info_pop(struct parser_params *parser, const if (token_info_has_nonspaces(parser, token) || ptinfo->nonspc) { /* SKIP */ goto finish; } - rb_warning("mismatched indentations: line %d:'%s' and line %d:'%s'", + rb_compile_warning(ruby_sourcefile, 0, + "mismatched indentations: line %d:'%s' and line %d:'%s'", ptinfo->linenum, ptinfo->token, linenum, token); finish: こんな感じですかね。 % ruby19 -w test0.rb /home/naruse/test.rb: warning: mismatched indentations: line 1:'class' and line 2:'end' こうなります。 -- NARUSE, Yui