Regexp.union behavior and Regexp.try_convert
Hi! Why Regexp.union('/../') trying to convert string with directly call rb_check_regexp_type(arg) (re.c:3139) instead of rb_reg_s_try_convert (re.c:3122)? I think second variant would be more correct, and i would be able to rewrite Regexp.try_convert in my code for changing behavior as i need.
For example: i have the code where was implemented String#to_regexp which breaks default behavior of Regexp.union and i got incorrect regexp. But i can't (for some reasons) to rewrite to_regexp method. Yes, stupid example, but it's real situation.
- re.c: [DOC] arguments of Regexp::union receive #to_regexp [Bug #8205]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43061 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
#2 [ruby-core:57014] Updated by avyy (Alexander Yunin) almost 5 years ago
Bug description is incorrect, sorry. Now i want to say that implementation of String#to_regexp can breaks behavior of Regexp::union.
Regexp.union('/some_regexp/') #=> /regexp/
And it's not documented now.
#3 [ruby-core:57161] Updated by nagachika (Tomoyuki Chikanaga) almost 5 years ago
- Category set to doc
- Status changed from Feedback to Assigned
- Assignee set to zzak (Zachary Scott)
- Target version set to 2.1.0
That makes sense.
I think it's spec that Regexp.union internally convert arguments with to_regexp, but it is undocumented behavior. I think it's a documentation issue.
#4 Updated by zzak (Zachary Scott) over 4 years ago
- Status changed from Assigned to Closed
- % Done changed from 0 to 100