summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Newton <kddnewton@gmail.com>2024-04-25 13:00:58 -0400
committergit <svn-admin@ruby-lang.org>2024-04-25 18:00:09 +0000
commitb6489e9f62dae9e62a4f978e0cb1091ab13c274c (patch)
tree78cb87c01e41e669d478eaeaf154cc0d330a6b36
parent444553b528a54a97e539de212ffc4c6466a6db20 (diff)
[ruby/prism] Remove need for Natalie patches
https://github.com/ruby/prism/commit/7fc7e13476
-rw-r--r--lib/prism/polyfill/string.rb6
1 files 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: