We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent dc54aee commit f625a9fCopy full SHA for f625a9f
src/main/ruby/truffleruby/core/match_data.rb
@@ -169,13 +169,14 @@ def to_s
169
def backref_from_arg(index)
170
if Primitive.is_a?(index, String) || Primitive.is_a?(index, Symbol)
171
names_to_backref = Hash[Primitive.regexp_names(self.regexp)]
172
- unless names_to_backref.key?(index.to_sym)
173
- raise IndexError, "undefined group name reference: #{index}"
174
- end
175
- names_to_backref[index.to_sym].last
176
- else
177
- Primitive.rb_to_int(index)
+ key = index.to_sym
+
+ raise IndexError, "undefined group name reference: #{index}" unless names_to_backref.key?(key)
+ return names_to_backref[key].last
178
end
179
+ Primitive.rb_to_int(index)
180
181
182
0 commit comments