You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think this only applies to Regexp.last_match with a Symbol argument, otherwise named captures work fine:
$ ruby -e '/(?<test>[A-Z]+.*)/.match "TEST123"; p $~[:test]; p Regexp.last_match :test'
"TEST123"
<internal:core> core/type.rb:277:in `convert_type': no implicit conversion of Symbol into Integer (TypeError)
from <internal:core> core/type.rb:186:in `rb_to_int_fallback'
from <internal:core> core/regexp.rb:83:in `last_match'
from -e:1:in `<main>'
There are several issues in the example above, match? won't set $? and the groups are non-capturing ((?:).
eregon
changed the title
Regexp does not take named captures
Regexp.last_match(Symbol) is not supported
Dec 7, 2020
I think this only applies to Regexp.last_match with a Symbol argument, otherwise named captures work fine:
$ ruby -e '/(?<test>[A-Z]+.*)/.match "TEST123"; p $~[:test]; p Regexp.last_match :test'
"TEST123"
<internal:core> core/type.rb:277:in `convert_type': no implicit conversion of Symbol into Integer (TypeError)
from <internal:core> core/type.rb:186:in `rb_to_int_fallback'
from <internal:core> core/regexp.rb:83:in `last_match'
from -e:1:in `<main>'
There are several issues in the example above, match? won't set $? and the groups are non-capturing ((?:).
Apologies, I just wanted a minimal test case to show you the stacktrace from Regexp. The actual one came from Jekyll and was way bigger.
The
Regexp
class does not parse or accept queries for named captures. This is a feature introduced in MRI 1.9.This currently breaks Jekyll 4.1.1 in truffleruby.
MWE (from
irb
):Using truffleruby 20.3.0 from rbenv.
The text was updated successfully, but these errors were encountered: