Better error message for missing optional-groups access in Regex #3978
Labels
good first issue
This is an issue suited for newcomers to become aquianted with working on the codebase.
kind:bug
topic:stdlib
The following code fails with a
Nil assertion failed
:Full stack trace being:
This happens because the first capturing group was optional, and not present in the current match, so when tried to be cast to
String
it fails. Note that usingString?
works.However, the error message should be more descriptive (similar to the
Missing hash key
when accessing a hash) to avoid confusion. See #3971 for example.The text was updated successfully, but these errors were encountered: