parser 3.0.3.2 → 3.1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e2251af231c276f8a7afbb8c5766ec286e076737a5446f3b453915243884684a
4
- data.tar.gz: 0045f0edcd07e6a0b152af2ea75146017fb0c0217584e2edc56d5eedcafe0f71
3
+ metadata.gz: 7ed45256e09de6d92098e12e73a655fe9d4f35518f573984bf1d92ac87ae8ded
4
+ data.tar.gz: 68ee7fca4f6d1794e2fb160552b01b983466cd482cad8783ba5f7b1466d0e70b
5
5
  SHA512:
6
- metadata.gz: 44814126d3b6b6e960e1044a320ca2e94cec80bef3a58be0dcb10b9ed92bb2ebe4c21ab4b446e3e14c65a8c4f18bd265252462d056944ad0e15c5928bcd58ba8
7
- data.tar.gz: da8145dd6a52dd3f4f9d4db73b4295d8df88dae974fac3df7db353a16ad95f45746066ddf98252ea3453660a2345d349cce8b2ca0e7f36bea2fade61cfd3368e
6
+ metadata.gz: 2f8f0785aba15f53c97b046aa5155ffeff4063b12fb611612bd7c3b94affb282487b5aad5ca783d2b928a91333db6e572a2a8a466fe9c7f5716354cb23644471
7
+ data.tar.gz: b8ecfc04463142cffb2aaad920e95e11257a1a6f7587bf439620b73e59102f15850c413dc807b613379678de9878aa2d941f3fa65ab20716f6be6d80fcf03299
@@ -714,7 +714,7 @@ module Parser
714
714
  node.updated(:gvasgn)
715
715
 
716
716
  when :const
717
- unless @parser.context.dynamic_const_definition_allowed?
717
+ if @parser.context.in_def
718
718
  diagnostic :error, :dynamic_const, nil, node.loc.expression
719
719
  end
720
720
 
@@ -16,60 +16,34 @@ module Parser
16
16
  # + :lambda - in the lambda body (-> {})
17
17
  #
18
18
  class Context
19
- attr_reader :stack
19
+ FLAGS = %i[
20
+ in_defined
21
+ in_kwarg
22
+ in_argdef
23
+ in_def
24
+ in_class
25
+ in_block
26
+ in_lambda
27
+ ]
20
28
 
21
29
  def initialize
22
- @stack = []
23
- freeze
24
- end
25
-
26
- def push(state)
27
- @stack << state
28
- end
29
-
30
- def pop
31
- @stack.pop
30
+ reset
32
31
  end
33
32
 
34
33
  def reset
35
- @stack.clear
36
- end
37
-
38
- def empty?
39
- @stack.empty?
40
- end
41
-
42
- def in_class?
43
- @stack.last == :class
44
- end
45
-
46
- def indirectly_in_def?
47
- @stack.include?(:def) || @stack.include?(:defs)
34
+ @in_defined = false
35
+ @in_kwarg = false
36
+ @in_argdef = false
37
+ @in_def = false
38
+ @in_class = false
39
+ @in_block = false
40
+ @in_lambda = false
48
41
  end
49
42
 
50
- def class_definition_allowed?
51
- def_index = stack.rindex { |item| [:def, :defs].include?(item) }
52
- sclass_index = stack.rindex(:sclass)
53
-
54
- def_index.nil? || (!sclass_index.nil? && sclass_index > def_index)
55
- end
56
- alias module_definition_allowed? class_definition_allowed?
57
- alias dynamic_const_definition_allowed? class_definition_allowed?
58
-
59
- def in_block?
60
- @stack.last == :block
61
- end
62
-
63
- def in_lambda?
64
- @stack.last == :lambda
65
- end
43
+ attr_accessor(*FLAGS)
66
44
 
67
45
  def in_dynamic_block?
68
- in_block? || in_lambda?
69
- end
70
-
71
- def in_def_open_args?
72
- @stack.last == :def_open_args
46
+ in_block || in_lambda
73
47
  end
74
48
  end
75
49
  end
@@ -93,7 +93,7 @@ module Parser
93
93
  CurrentRuby = Ruby30
94
94
 
95
95
  when /^3\.1\./
96
- current_version = '3.1.0-dev'
96
+ current_version = '3.1.0'
97
97
  if RUBY_VERSION != current_version
98
98
  warn_syntax_deviation 'parser/ruby31', current_version
99
99
  end
@@ -103,8 +103,8 @@ module Parser
103
103
 
104
104
  else # :nocov:
105
105
  # Keep this in sync with released Ruby.
106
- warn_syntax_deviation 'parser/ruby30', '3.0.x'
107
- require 'parser/ruby30'
108
- CurrentRuby = Ruby30
106
+ warn_syntax_deviation 'parser/ruby31', '3.1.x'
107
+ require 'parser/ruby31'
108
+ CurrentRuby = Ruby31
109
109
  end
110
110
  end
@@ -18,7 +18,7 @@ module Parser
18
18
  def advance
19
19
  type, (val, range) = advance_before_explanation
20
20
 
21
- more = "(in-kwarg)" if @in_kwarg
21
+ more = "(in-kwarg)" if @context.in_kwarg
22
22
 
23
23
  puts decorate(range,
24
24
  Color.green("#{type} #{val.inspect}"),