This isn't even possible to work around by targeting RUBY_VERSION, as Ruby warns even in unreachable cases: ```ruby regex = if RUBY_VERSION < '4' /[\p{Word}\p{Cf}]/ else /[\p{Word}]/ end ``` still warns on Ruby 4+, even t...jneen (Jeanine Adkisson)
That's a very interesting find! I do think it makes sense to warn if an explicitly written character repeats in a character class, or if the class begins and ends with a colon. But for overlapping unicode properties, there doesn't see...jneen (Jeanine Adkisson)
trinistr (Alexander Bulancov) wrote in #note-11: > > Using `/(\p{Word}|\p{S})/` is kind of a workaround, but it is slower. > ... This is what I actually tested. Still much slower. mame (Yusuke Endoh) wrote in #note-9: > jneen (Jeanine A...jneen (Jeanine Adkisson)
That specific case also appears to have changed, e.g. on 3.4.1: ```ruby [2] pry(main)> (0..0x10ffff).select{(s=[it].pack('U'); s=~/\p{Word}/&&s=~/\p{Cf}/) rescue false}.map{it.to_s 16} => [] ``` Maybe for preset classes like `\p...jneen (Jeanine Adkisson)
Another example of this is `/[\p{Word}\p{Cf}]/`, which seem to overlap precisely on ZWNJ (U+200C) and ZWJ (U+200D). ```ruby [1] pry(main)> (0..0x10ffff).select{(s=[it].pack('U'); s=~/\p{Word}/&&s=~/\p{Cf}/) rescue false}.map{it.to_s ...jneen (Jeanine Adkisson)
I wonder if exposing a static `Object.class_of(thing)` would be appropriate? There's also the singleton_class to consider as well.jneen (Jeanine Adkisson)
I see! So they do have some overlap. Is it really correct to warn here though? "Fixing" the warning would require falling back to manual unicode ranges.jneen (Jeanine Adkisson)
```ruby $VERBOSE = true # warning: character class has duplicated range: /[\p{Word}\p{S}]/ regex = /[\p{Word}\p{S}]/ ``` As far as I can tell this is a perfectly valid and non-redundant set of unicode properties, but I am still be...jneen (Jeanine Adkisson)
In fact, I believe this is still happening somewhat with IRB, in that the entire program seems to be run in the root box, and TOPLEVEL_BINDING changes are not visible: ``` $ ./bin/irb irb(main):001> TOPLEVEL_BINDING.eval("A = 1") => 1 ...jneen (Jeanine Adkisson)