[Closed] Ripper.sexp("foo\n .bar") extract a wrong method name " .bar"

Issue #10411 has been updated by Nobuyoshi N…

Status changed from Open to Closed
% Done changed from 0 to 100

Applied in changeset r48126.


parse.y: fix fluent interface identifier

  • parse.y (parser_yylex): dispatch newline and space at fluent
    interface, so that the following identifier does not include the
    space. [ruby-dev:48684] [Bug #10411]

Bug #10411: Ripper.sexp(“foo\n .bar”) extract a wrong method
name " .bar"

  • Author: Akira T.
  • Status: Closed
  • Priority: Normal
  • Assignee:
  • Category:
  • Target version:
  • ruby -v: ruby 2.2.0dev (2014-10-22 trunk 48083) [x86_64-linux]
  • Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN

以下のように、ripper が、メソッド名として " .bar" などといった
空白やピリオドの入った文字列を取り出してくることがあります。

% ./ruby -v -rripper -e 'p Ripper.sexp("foo\n         .bar")'
ruby 2.2.0dev (2014-10-22 trunk 48083) [x86_64-linux]
[:program, [[:call, [:vcall, [:@ident, "foo", [1, 0]]], :".", [:@ident, 
"         .bar", [2, 0]]]]]

改行を入れなければ、“bar” という期待するメソッド名が取り出されます。

% ./ruby -rripper -e 'p Ripper.sexp("foo         .bar")'
[:program, [[:call, [:vcall, [:@ident, "foo", [1, 0]]], :".", [:@ident, 
"bar", [1, 13]]]]]