ruby-next-core 0.15.2 → 0.15.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c392536e2de07a838a8c9818b0651a9d2eb6803471f52d1e3632bada3fb398a4
4
- data.tar.gz: 564822b7a5c55ec7fc278bf223206f0b16a75a71a9277b247d862489c7a342cb
3
+ metadata.gz: 6020fe263af1a0313e82b5633c45ee76950e7d39bd1f4e70f9d2613eb6ba3fec
4
+ data.tar.gz: 3a1c6da894f68e5e703f0515239bf342852d45f4f5672f68f8fe4011a0e76c57
5
5
  SHA512:
6
- metadata.gz: 33d80d8d5bfaaf75cc0cc42b79eb4758ff57c9d72f1ac21eb86770f1f039c79cebc7eabc5b4a20c42e11a9a266b8a435849b2a4ae74547acd6b9a8fb8db03f39
7
- data.tar.gz: 1a9b048897ad763e2dd726bc0be7112337499dbb1ddad9e02f13b81a2bb98d28d6f32f2e9abe1e29222a05895433117e082a5a8e42be4101d4d4eb056bcf5c61
6
+ metadata.gz: dffe0bf9d32e02cd71aee8f5818d4413a62d96c8d595706c476bee2990823cf960240162b79d51d62036d2bb4a0076b46cba5af93c58760064aae165a82cd6e4
7
+ data.tar.gz: 22879525ffbbbd38921b096ef909ad79d5a87d726dae39f6a108aea2dc82ae5605e6a8e1bd9a190689e0a5da66fc897c6d8d22590f9a237416cd9a79aca43a38
data/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## master
4
4
 
5
+ ## 0.15.3 (2022-10-16)
6
+
7
+ - Fix handling nested const patterns. ([@palkan][])
8
+
5
9
  ## 0.15.2 (2022-08-02)
6
10
 
7
11
  - Fix loading transpiled in TruffleRuby. ([@palkan][])
@@ -425,15 +425,15 @@ module RubyNext
425
425
  s(:begin,
426
426
  s(:and,
427
427
  node,
428
- send(:"#{pattern.type}_clause", pattern)))
428
+ send(:"#{pattern.type}_clause", pattern, right)))
429
429
  end
430
430
  end
431
431
 
432
- def match_alt_clause(node)
432
+ def match_alt_clause(node, matchee = s(:lvar, locals[:matchee]))
433
433
  children = locals.with(ALTERNATION_MARKER => true) do
434
434
  node.children.map.with_index do |child, i|
435
435
  predicates.terminate! if i == 1
436
- send :"#{child.type}_clause", child
436
+ send :"#{child.type}_clause", child, matchee
437
437
  end
438
438
  end
439
439
  s(:begin, s(:or, *children))
@@ -663,6 +663,14 @@ module RubyNext
663
663
  end
664
664
  end
665
665
 
666
+ def const_pattern_array_element(node, index)
667
+ element = arr_item_at(index)
668
+ locals.with(arr: locals[:arr, index]) do
669
+ predicates.push :"i#{index}"
670
+ const_pattern_clause(node, element).tap { predicates.pop }
671
+ end
672
+ end
673
+
666
674
  def match_alt_array_element(node, index)
667
675
  children = node.children.map do |child, i|
668
676
  send :"#{child.type}_array_element", child, index
@@ -671,11 +679,19 @@ module RubyNext
671
679
  end
672
680
 
673
681
  def match_var_array_element(node, index)
674
- match_var_clause(node, arr_item_at(index))
682
+ element = arr_item_at(index)
683
+ locals.with(arr: locals[:arr, index]) do
684
+ predicates.push :"i#{index}"
685
+ match_var_clause(node, element).tap { predicates.pop }
686
+ end
675
687
  end
676
688
 
677
689
  def match_as_array_element(node, index)
678
- match_as_clause(node, arr_item_at(index))
690
+ element = arr_item_at(index)
691
+ locals.with(arr: locals[:arr, index]) do
692
+ predicates.push :"i#{index}"
693
+ match_as_clause(node, element).tap { predicates.pop }
694
+ end
679
695
  end
680
696
 
681
697
  def pin_array_element(node, index)
@@ -844,6 +860,15 @@ module RubyNext
844
860
  end
845
861
  end
846
862
 
863
+ def const_pattern_hash_element(node, key)
864
+ element = hash_value_at(key)
865
+ key_index = deconstructed_key(key)
866
+ locals.with(hash: locals[:hash, key_index]) do
867
+ predicates.push :"k#{key_index}"
868
+ const_pattern_clause(node, element).tap { predicates.pop }
869
+ end
870
+ end
871
+
847
872
  def hash_element(head, *tail)
848
873
  send("#{head.type}_hash_element", head).then do |node|
849
874
  next node if tail.empty?
@@ -884,12 +909,22 @@ module RubyNext
884
909
  end
885
910
 
886
911
  def match_as_hash_element(node, key)
887
- match_as_clause(node, hash_value_at(key))
912
+ element = hash_value_at(key)
913
+ key_index = deconstructed_key(key)
914
+ locals.with(hash: locals[:hash, key_index]) do
915
+ predicates.push :"k#{key_index}"
916
+ match_as_clause(node, element).tap { predicates.pop }
917
+ end
888
918
  end
889
919
 
890
920
  def match_var_hash_element(node, key = nil)
891
921
  key ||= node.children[0]
892
- match_var_clause(node, hash_value_at(key))
922
+ element = hash_value_at(key)
923
+ key_index = deconstructed_key(key)
924
+ locals.with(hash: locals[:hash, key_index]) do
925
+ predicates.push :"k#{key_index}"
926
+ match_var_clause(node, element).tap { predicates.pop }
927
+ end
893
928
  end
894
929
 
895
930
  def match_nil_pattern_hash_element(node, _key = nil)
@@ -425,15 +425,15 @@ module RubyNext
425
425
  s(:begin,
426
426
  s(:and,
427
427
  node,
428
- send(:"#{pattern.type}_clause", pattern)))
428
+ send(:"#{pattern.type}_clause", pattern, right)))
429
429
  end
430
430
  end
431
431
 
432
- def match_alt_clause(node)
432
+ def match_alt_clause(node, matchee = s(:lvar, locals[:matchee]))
433
433
  children = locals.with(ALTERNATION_MARKER => true) do
434
434
  node.children.map.with_index do |child, i|
435
435
  predicates.terminate! if i == 1
436
- send :"#{child.type}_clause", child
436
+ send :"#{child.type}_clause", child, matchee
437
437
  end
438
438
  end
439
439
  s(:begin, s(:or, *children))
@@ -663,6 +663,14 @@ module RubyNext
663
663
  end
664
664
  end
665
665
 
666
+ def const_pattern_array_element(node, index)
667
+ element = arr_item_at(index)
668
+ locals.with(arr: locals[:arr, index]) do
669
+ predicates.push :"i#{index}"
670
+ const_pattern_clause(node, element).tap { predicates.pop }
671
+ end
672
+ end
673
+
666
674
  def match_alt_array_element(node, index)
667
675
  children = node.children.map do |child, i|
668
676
  send :"#{child.type}_array_element", child, index
@@ -671,11 +679,19 @@ module RubyNext
671
679
  end
672
680
 
673
681
  def match_var_array_element(node, index)
674
- match_var_clause(node, arr_item_at(index))
682
+ element = arr_item_at(index)
683
+ locals.with(arr: locals[:arr, index]) do
684
+ predicates.push :"i#{index}"
685
+ match_var_clause(node, element).tap { predicates.pop }
686
+ end
675
687
  end
676
688
 
677
689
  def match_as_array_element(node, index)
678
- match_as_clause(node, arr_item_at(index))
690
+ element = arr_item_at(index)
691
+ locals.with(arr: locals[:arr, index]) do
692
+ predicates.push :"i#{index}"
693
+ match_as_clause(node, element).tap { predicates.pop }
694
+ end
679
695
  end
680
696
 
681
697
  def pin_array_element(node, index)
@@ -844,6 +860,15 @@ module RubyNext
844
860
  end
845
861
  end
846
862
 
863
+ def const_pattern_hash_element(node, key)
864
+ element = hash_value_at(key)
865
+ key_index = deconstructed_key(key)
866
+ locals.with(hash: locals[:hash, key_index]) do
867
+ predicates.push :"k#{key_index}"
868
+ const_pattern_clause(node, element).tap { predicates.pop }
869
+ end
870
+ end
871
+
847
872
  def hash_element(head, *tail)
848
873
  send("#{head.type}_hash_element", head).then do |node|
849
874
  next node if tail.empty?
@@ -884,12 +909,22 @@ module RubyNext
884
909
  end
885
910
 
886
911
  def match_as_hash_element(node, key)
887
- match_as_clause(node, hash_value_at(key))
912
+ element = hash_value_at(key)
913
+ key_index = deconstructed_key(key)
914
+ locals.with(hash: locals[:hash, key_index]) do
915
+ predicates.push :"k#{key_index}"
916
+ match_as_clause(node, element).tap { predicates.pop }
917
+ end
888
918
  end
889
919
 
890
920
  def match_var_hash_element(node, key = nil)
891
921
  key ||= node.children[0]
892
- match_var_clause(node, hash_value_at(key))
922
+ element = hash_value_at(key)
923
+ key_index = deconstructed_key(key)
924
+ locals.with(hash: locals[:hash, key_index]) do
925
+ predicates.push :"k#{key_index}"
926
+ match_var_clause(node, element).tap { predicates.pop }
927
+ end
893
928
  end
894
929
 
895
930
  def match_nil_pattern_hash_element(node, _key = nil)
@@ -425,15 +425,15 @@ module RubyNext
425
425
  s(:begin,
426
426
  s(:and,
427
427
  node,
428
- send(:"#{pattern.type}_clause", pattern)))
428
+ send(:"#{pattern.type}_clause", pattern, right)))
429
429
  end
430
430
  end
431
431
 
432
- def match_alt_clause(node)
432
+ def match_alt_clause(node, matchee = s(:lvar, locals[:matchee]))
433
433
  children = locals.with(ALTERNATION_MARKER => true) do
434
434
  node.children.map.with_index do |child, i|
435
435
  predicates.terminate! if i == 1
436
- send :"#{child.type}_clause", child
436
+ send :"#{child.type}_clause", child, matchee
437
437
  end
438
438
  end
439
439
  s(:begin, s(:or, *children))
@@ -663,6 +663,14 @@ module RubyNext
663
663
  end
664
664
  end
665
665
 
666
+ def const_pattern_array_element(node, index)
667
+ element = arr_item_at(index)
668
+ locals.with(arr: locals[:arr, index]) do
669
+ predicates.push :"i#{index}"
670
+ const_pattern_clause(node, element).tap { predicates.pop }
671
+ end
672
+ end
673
+
666
674
  def match_alt_array_element(node, index)
667
675
  children = node.children.map do |child, i|
668
676
  send :"#{child.type}_array_element", child, index
@@ -671,11 +679,19 @@ module RubyNext
671
679
  end
672
680
 
673
681
  def match_var_array_element(node, index)
674
- match_var_clause(node, arr_item_at(index))
682
+ element = arr_item_at(index)
683
+ locals.with(arr: locals[:arr, index]) do
684
+ predicates.push :"i#{index}"
685
+ match_var_clause(node, element).tap { predicates.pop }
686
+ end
675
687
  end
676
688
 
677
689
  def match_as_array_element(node, index)
678
- match_as_clause(node, arr_item_at(index))
690
+ element = arr_item_at(index)
691
+ locals.with(arr: locals[:arr, index]) do
692
+ predicates.push :"i#{index}"
693
+ match_as_clause(node, element).tap { predicates.pop }
694
+ end
679
695
  end
680
696
 
681
697
  def pin_array_element(node, index)
@@ -844,6 +860,15 @@ module RubyNext
844
860
  end
845
861
  end
846
862
 
863
+ def const_pattern_hash_element(node, key)
864
+ element = hash_value_at(key)
865
+ key_index = deconstructed_key(key)
866
+ locals.with(hash: locals[:hash, key_index]) do
867
+ predicates.push :"k#{key_index}"
868
+ const_pattern_clause(node, element).tap { predicates.pop }
869
+ end
870
+ end
871
+
847
872
  def hash_element(head, *tail)
848
873
  send("#{head.type}_hash_element", head).then do |node|
849
874
  next node if tail.empty?
@@ -884,12 +909,22 @@ module RubyNext
884
909
  end
885
910
 
886
911
  def match_as_hash_element(node, key)
887
- match_as_clause(node, hash_value_at(key))
912
+ element = hash_value_at(key)
913
+ key_index = deconstructed_key(key)
914
+ locals.with(hash: locals[:hash, key_index]) do
915
+ predicates.push :"k#{key_index}"
916
+ match_as_clause(node, element).tap { predicates.pop }
917
+ end
888
918
  end
889
919
 
890
920
  def match_var_hash_element(node, key = nil)
891
921
  key ||= node.children[0]
892
- match_var_clause(node, hash_value_at(key))
922
+ element = hash_value_at(key)
923
+ key_index = deconstructed_key(key)
924
+ locals.with(hash: locals[:hash, key_index]) do
925
+ predicates.push :"k#{key_index}"
926
+ match_var_clause(node, element).tap { predicates.pop }
927
+ end
893
928
  end
894
929
 
895
930
  def match_nil_pattern_hash_element(node, _key = nil)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RubyNext
4
- VERSION = "0.15.2"
4
+ VERSION = "0.15.3"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-next-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.15.2
4
+ version: 0.15.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vladimir Dementyev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-08-02 00:00:00.000000000 Z
11
+ date: 2022-10-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruby-next-parser
@@ -171,7 +171,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
171
171
  - !ruby/object:Gem::Version
172
172
  version: '0'
173
173
  requirements: []
174
- rubygems_version: 3.3.7
174
+ rubygems_version: 3.3.11
175
175
  signing_key:
176
176
  specification_version: 4
177
177
  summary: Ruby Next core functionality