Closed jaynetics closed 7 years ago
@ammar I couldn’t find any information about this myself, but there must have been some kind of change:
irb(main):001:0> RUBY_VERSION
=> "2.3.0"
irb(main):002:0> /(?(1)b|c)/
=> /(?(1)b|c)/
irb(main):001:0> RUBY_VERSION
=> "2.4.0"
irb(main):002:0> /(?(1)b|c)/
SyntaxError: (irb):2: invalid backref number/name: /(?(1)b|c)/
I see. Thanks.
It looks like the new version of Onigmo checks the validity of the backrefs. The following works fine because the referenced backref (1) actually exists:
>> RUBY_VERSION
=> "2.4.0"
>> /(a)(?(1)b|c)/
=> /(a)(?(1)b|c)/
I think it's the tests that are no longer acceptable by the Onigmo version in ruby 2.4.
Exactly. Maybe my commit message was a bit misleading there. I didn’t mean to say that backreferences are no longer allowed in Ruby 2.4 - just that invalid (or "void") backreferences are now disallowed.
Got it. I see now that your note was accurate, I misread it.
It looks good. Thanks again!
Thanks for merging!
Pushed regexp_parser 0.4.2 to rubygems.org
@janosch-x Thanks for this and sorry about the late response.
Can you please point me to information about disallowing back references in ruby 2.4?
The only related information I found in NEWS was about introducing a new
Regexp
method (#match?
) that does not save back references to reduce object allocation. This does not seem to be a global change.