diff options
Diffstat (limited to 'lib/prism')
-rw-r--r-- | lib/prism/polyfill/string.rb | 12 | ||||
-rw-r--r-- | lib/prism/prism.gemspec | 1 |
2 files changed, 13 insertions, 0 deletions
diff --git a/lib/prism/polyfill/string.rb b/lib/prism/polyfill/string.rb new file mode 100644 index 0000000000..582266d956 --- /dev/null +++ b/lib/prism/polyfill/string.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +# Polyfill for String#unpack1 with the offset parameter. +if String.instance_method(:unpack1).parameters.none? { |_, name| name == :offset } + String.prepend( + Module.new { + def unpack1(format, offset: 0) # :nodoc: + offset == 0 ? super(format) : self[offset..].unpack1(format) # steep:ignore + end + } + ) +end diff --git a/lib/prism/prism.gemspec b/lib/prism/prism.gemspec index 1ad2da35c4..d43fcfd36b 100644 --- a/lib/prism/prism.gemspec +++ b/lib/prism/prism.gemspec @@ -87,6 +87,7 @@ Gem::Specification.new do |spec| "lib/prism/parse_result/comments.rb", "lib/prism/parse_result/newlines.rb", "lib/prism/pattern.rb", + "lib/prism/polyfill/string.rb", "lib/prism/serialize.rb", "lib/prism/translation.rb", "lib/prism/translation/parser.rb", |