Project

General

Profile

Actions

Feature #5484

closed

regexp comparison bug

Added by ddebernardy (Denis de Bernardy) about 13 years ago. Updated over 12 years ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:40364]

Description

Based on ri Regexp.eql?:

Equality---Two regexps are equal if their patterns are identical, they have
the same character set code, and their casefold? values are the same.

/abc/ == /abc/x #=> false
/abc/ == /abc/i #=> false
/abc/ == /abc/n #=> false
/abc/u == /abc/n #=> false

However:

a = Regexp.new("/foo")
=> //foo/
b = //foo/
=> //foo/
a == b
=> false

The only meaningful difference between the two is the exact source:

a.source
=> "/foo"
b.source
=> "\/foo"

But I'd argue that a's source should be normalized to that of b, or vice-versa, since their string representations are identical.

Actions #1

Updated by naruse (Yui NARUSE) about 13 years ago

  • Tracker changed from Bug to Feature

I think this is from a policy of comparison, not a bug.
If you have a reason that Ruby change the policy, please show us.
We'll change the policy if it is reasonable.

Updated by ddebernardy (Denis de Bernardy) over 12 years ago

Well, I originally reported it as a bug, since I got bit by it. I can't recall the context let alone the specifics.

Anyway... Feel free to close if you think this is to be expected (I'd argue it shouldn't...)

Actions #3

Updated by nobu (Nobuyoshi Nakada) over 12 years ago

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

This issue was solved with changeset r34896.
Denis, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


  • parse.y (parser_tokadd_string): regexp engine doesn't need
    terminators to be escaped. [ruby-core:40364][Bug #5484]
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0