Sha256: fdfb70f7c5cefc5f267477cf5818e4b875f9d95ce661f07516f5df4d522baa9c
Contents?: true
Size: 1.26 KB
Versions: 11
Compression:
Stored size: 1.26 KB
Contents
# frozen_string_literal: true module RubyNext module Language module Rewriters using RubyNext # Separate pattern matching rewriter for Ruby 2.7 and 3.0 to # transpile only ^(ivar|cvar|gvar) class PinVarsPattern < PatternMatching NAME = "pattern-matching-pin-vars" SYNTAX_PROBE = "@a = 0; case 0; in ^@a; true; end" MIN_SUPPORTED_VERSION = Gem::Version.new("3.1.0") def on_case_match(node) @has_pin_vars = false process_regular_node(node).then do |new_node| return new_node unless has_pin_vars super(node) end end def on_match_pattern(node) @has_pin_vars = false process_regular_node(node).then do |new_node| return new_node unless has_pin_vars super(node) end end def on_match_pattern_p(node) @has_pin_vars = false process_regular_node(node).then do |new_node| return new_node unless has_pin_vars super(node) end end def on_pin(node) @has_pin_vars = node.children.first.type != :lvar super(node) end private attr_reader :has_pin_vars end end end end
Version data entries
11 entries across 11 versions & 1 rubygems