Ruby -c and ripper inconsistency: /(?<n>a(b|\g<n>))/


#1

Issue #10543 has been updated by Nobuyoshi N…

Related to Bug #10437: ruby -c and ripper inconsistency: /*/ added


Bug #10543: ruby -c and ripper inconsistency: /(?a(b|\g))/
https://bugs.ruby-lang.org/issues/10543#change-50213

  • Author: Akira T.
  • Status: Closed
  • Priority: Normal
  • Assignee:
  • Category:
  • Target version:
  • ruby -v: ruby 2.2.0dev (2014-11-26 trunk 48577) [x86_64-linux]
  • Backport: 2.0.0: DONTNEED, 2.1: DONTNEED

以下のように、/(?a(b|\g))/ というだけのソースは
ruby -c では問題無しとなりますが、
Ripper.sexp では構文木でなく nil が返ってきてしまいます。

% cat z.rb
/(?<n>a(b|\g<n>))/
% ./ruby -c z.rb
Syntax OK
% ./ruby -rripper -e 'p Ripper.sexp(STDIN.read)' < z.rb
nil
% ./ruby -v
ruby 2.2.0dev (2014-11-26 trunk 48577) [x86_64-linux]