From 6cab599c35bd1a4cced5b99bf7fbc66623468e36 Mon Sep 17 00:00:00 2001 From: Jaime Rave Torres Date: Mon, 31 Aug 2020 19:37:33 +0200 Subject: [PATCH] Add workaround to avoid crash in Truffleruby (#8602) --- CHANGELOG.md | 2 ++ lib/rubocop/cop/utils/format_string.rb | 8 +++----- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3e341fb19ce..a4aab64bd0d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -43,6 +43,7 @@ * [#8513](https://github.com/rubocop-hq/rubocop/pull/8513): Clarify the ruby warning mentioned in the `Lint/ShadowingOuterLocalVariable` documentation. ([@chocolateboy][]) * [#8517](https://github.com/rubocop-hq/rubocop/pull/8517): Make `Style/HashTransformKeys` and `Style/HashTransformValues` aware of `to_h` with block. ([@eugeneius][]) * [#8529](https://github.com/rubocop-hq/rubocop/pull/8529): Mark `Lint/FrozenStringLiteralComment` as `Safe`, but with unsafe auto-correction. ([@marcandre][]) +* [#8602](https://github.com/rubocop-hq/rubocop/pull/8602): Fix usage of `to_enum(:scan, regexp)` to work on TruffleRuby. ([@jaimerave][]) ## 0.89.1 (2020-08-10) @@ -4819,3 +4820,4 @@ [@nguyenquangminh0711]: https://github.com/nguyenquangminh0711 [@chocolateboy]: https://github.com/chocolateboy [@Lykos]: https://github.com/Lykos +[@jaimerave]: https://github.com/jaimerave diff --git a/lib/rubocop/cop/utils/format_string.rb b/lib/rubocop/cop/utils/format_string.rb index 96de5f8f18f..4d130b6dca5 100644 --- a/lib/rubocop/cop/utils/format_string.rb +++ b/lib/rubocop/cop/utils/format_string.rb @@ -111,11 +111,9 @@ def max_digit_dollar_num private def parse - @source.to_enum(:scan, SEQUENCE).map do - FormatSequence.new( - Regexp.last_match - ) - end + matches = [] + @source.scan(SEQUENCE) { matches << FormatSequence.new(Regexp.last_match) } + matches end def mixed_formats?