summaryrefslogtreecommitdiff
path: root/lib/prism/translation/parser/compiler.rb
diff options
context:
space:
mode:
authorKevin Newton <kddnewton@gmail.com>2024-02-05 15:41:46 -0500
committergit <svn-admin@ruby-lang.org>2024-02-07 16:54:34 +0000
commitaad3c36bdfe68c429cf612542a7eb3c94c17c483 (patch)
tree70cff5280c6d97d131501a9e8dc774c33ac3e31c /lib/prism/translation/parser/compiler.rb
parentaed052ce9d9eeeccecb12c444aa7327d1e078a51 (diff)
[ruby/prism] Support for Ruby 2.7
https://github.com/ruby/prism/commit/1a15b70a8e
Diffstat (limited to 'lib/prism/translation/parser/compiler.rb')
-rw-r--r--lib/prism/translation/parser/compiler.rb22
1 files changed, 16 insertions, 6 deletions
diff --git a/lib/prism/translation/parser/compiler.rb b/lib/prism/translation/parser/compiler.rb
index 45a5191154..264d85c261 100644
--- a/lib/prism/translation/parser/compiler.rb
+++ b/lib/prism/translation/parser/compiler.rb
@@ -1062,12 +1062,22 @@ module Prism
# foo in bar
# ^^^^^^^^^^
- def visit_match_predicate_node(node)
- builder.match_pattern_p(
- visit(node.value),
- token(node.operator_loc),
- within_pattern { |compiler| node.pattern.accept(compiler) }
- )
+ if RUBY_VERSION >= "3.0"
+ def visit_match_predicate_node(node)
+ builder.match_pattern_p(
+ visit(node.value),
+ token(node.operator_loc),
+ within_pattern { |compiler| node.pattern.accept(compiler) }
+ )
+ end
+ else
+ def visit_match_predicate_node(node)
+ builder.match_pattern(
+ visit(node.value),
+ token(node.operator_loc),
+ within_pattern { |compiler| node.pattern.accept(compiler) }
+ )
+ end
end
# foo => bar