Description: Make NotRubyParser compatible with prism 0.19.0 in Debian/Ubuntu
 Conditionalize the definition of NotRubyParser so it falls back to the
 classic RubyParser (from the ruby_parser gem) when Prism::Translation::RubyParser
 is not available (as in prism 0.19.0 shipped with ruby3.3). On newer Prism
 versions (>= 0.23) it uses the upstream-intended translation layer.
Author: Simon Quigley <tsimonq2@debian.org>
Origin: vendor
Forwarded: not-needed
Last-Update: 2026-02-23
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- a/test/test_ruby2ruby.rb
+++ b/test/test_ruby2ruby.rb
@@ -13,17 +13,30 @@ require "prism"
 require "timeout" # remove once upstreamed
 # require "prism/translation/ruby_parser" # not until upstreamed
 
-class NotRubyParser < Prism::Translation::RubyParser # remove once upstreamed
-  attr_accessor :scopes
+if defined?(Prism::Translation::RubyParser)
+  class NotRubyParser < Prism::Translation::RubyParser # remove once upstreamed
+    attr_accessor :scopes
 
-  def initialize scopes:nil
-    super()
-    self.scopes = [scopes] if scopes
+    def initialize(scopes: nil)
+      super()
+      self.scopes = [scopes] if scopes
+    end
+
+    # overridden from prism to add scopes arg (exactly as upstream intended)
+    def parse(source, filepath = "(string)")
+      translate(Prism.parse(source, filepath:, partial_script: true, scopes:), filepath)
+    end
   end
+else
+  require "ruby_parser"
+
+  class NotRubyParser < RubyParser
+    attr_accessor :scopes
 
-  # overridden from prism to add scopes arg
-  def parse(source, filepath = "(string)")
-    translate(Prism.parse(source, filepath:, partial_script: true, scopes:), filepath)
+    def initialize(scopes: nil)
+      super()
+      self.scopes = [scopes] if scopes
+    end
   end
 end
 
