diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb index d87b835628..6eb651979d 100644 --- a/Library/Homebrew/utils.rb +++ b/Library/Homebrew/utils.rb @@ -143,11 +143,11 @@ module Utils # `ActiveSupport::Inflector.underscore` sig { params(camel_cased_word: T.any(String, Symbol)).returns(String) } def self.underscore(camel_cased_word) - return camel_cased_word unless /[A-Z-]|::/.match?(camel_cased_word) + return camel_cased_word.to_s unless /[A-Z-]|::/.match?(camel_cased_word) word = camel_cased_word.to_s.gsub("::", "/") word.gsub!(/([A-Z])(?=[A-Z][a-z])|([a-z\d])(?=[A-Z])/) do - (::Regexp.last_match(1) || ::Regexp.last_match(2)) << "_" + T.must(::Regexp.last_match(1) || ::Regexp.last_match(2)) << "_" end word.tr!("-", "_") word.downcase!