From b6489e9f62dae9e62a4f978e0cb1091ab13c274c Mon Sep 17 00:00:00 2001 From: Kevin Newton Date: Thu, 25 Apr 2024 13:00:58 -0400 Subject: [PATCH] [ruby/prism] Remove need for Natalie patches https://github.com/ruby/prism/commit/7fc7e13476 --- lib/prism/polyfill/string.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/prism/polyfill/string.rb b/lib/prism/polyfill/string.rb index 582266d956..3fa9b5a0c5 100644 --- a/lib/prism/polyfill/string.rb +++ b/lib/prism/polyfill/string.rb @@ -1,7 +1,9 @@ # frozen_string_literal: true -# Polyfill for String#unpack1 with the offset parameter. -if String.instance_method(:unpack1).parameters.none? { |_, name| name == :offset } +# Polyfill for String#unpack1 with the offset parameter. Not all Ruby engines +# have Method#parameters implemented, so we check the arity instead if +# necessary. +if (unpack1 = String.instance_method(:unpack1)).respond_to?(:parameters) ? unpack1.parameters.none? { |_, name| name == :offset } : (unpack1.arity == 1) String.prepend( Module.new { def unpack1(format, offset: 0) # :nodoc: