parser 3.2.2.4 → 3.3.0.3

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: 8565383a05692fe05c5f0962a0cb6c4594ad1eaab98f8e1c8b1053ddfa665858
4
- data.tar.gz: 280636e65eab161acc6369cdf992faa4f81a6496ebbbad794a96ee60ea3e4884
3
+ metadata.gz: c7231a53f195d9ffb6763bfb93c91629905199a9a54ff843bf971e3b189ef43b
4
+ data.tar.gz: 381b37d3a35dcfa3a0f3c39bd63acc42a5252e7ccbdbe2c2042da4dfeb60994d
5
5
  SHA512:
6
- metadata.gz: 8721d3c59c29a9bcb9562b6f0bad1ca119f854873fb3b6f5e550553a6d2fa471afb2d3e1c6c5b1323d5121b36f4070ed0a3bca24866b3dede1682658bbce934f
7
- data.tar.gz: e312e821428e6c15ec871971aabee38cd7c238adfc855ff1a4b70edb31f529e359162c1961141d2ce3fe0d5f6aee3fce009c6a479aaa3909920993af58d3c3f2
6
+ metadata.gz: 5fe3d36527bbec8ab859c594b124fe24a35507c879486ef3b6edb16aac0d877dcc3e05fd408caed4d05a7569bdfb986b78f14849c3db3e814de32d6750714a1a
7
+ data.tar.gz: 93bd5eb05dbd5a57bc3e10ffb5acace2b5dfad6ab7ca2c65299b9f337acd15db905d5bcadcea48e5bb9895d09ed8cfa9c45cee129474d0518b4731a513fd22f7
@@ -594,7 +594,13 @@ module Parser
594
594
  end
595
595
 
596
596
  def gvar(token)
597
- n(:gvar, [ value(token).to_sym ],
597
+ gvar_name = value(token)
598
+
599
+ if gvar_name.start_with?('$0') && gvar_name.length > 2
600
+ diagnostic :error, :gvar_name, { :name => gvar_name }, loc(token)
601
+ end
602
+
603
+ n(:gvar, [ gvar_name.to_sym ],
598
604
  variable_map(token))
599
605
  end
600
606
 
@@ -654,6 +660,13 @@ module Parser
654
660
  end
655
661
 
656
662
  unless @parser.static_env.declared?(name)
663
+ if @parser.version == 33 &&
664
+ name == :it &&
665
+ @parser.context.in_block &&
666
+ !@parser.max_numparam_stack.has_ordinary_params?
667
+ diagnostic :warning, :ambiguous_it_call, nil, node.loc.expression
668
+ end
669
+
657
670
  return n(:send, [ nil, name ],
658
671
  var_send_map(node))
659
672
  end
@@ -2255,6 +2268,10 @@ module Parser
2255
2268
 
2256
2269
  def static_regexp_node(node)
2257
2270
  if node.type == :regexp
2271
+ if @parser.version >= 33 && node.children[0..-2].any? { |child| child.type != :str }
2272
+ return nil
2273
+ end
2274
+
2258
2275
  parts, options = node.children[0..-2], node.children[-1]
2259
2276
  static_regexp(parts, options)
2260
2277
  end
@@ -111,7 +111,7 @@ module Parser
111
111
  CurrentRuby = Ruby32
112
112
 
113
113
  when /^3\.3\./
114
- current_version = '3.3.0-dev'
114
+ current_version = '3.3.0'
115
115
  if RUBY_VERSION != current_version
116
116
  warn_syntax_deviation 'parser/ruby33', current_version
117
117
  end
@@ -121,8 +121,8 @@ module Parser
121
121
 
122
122
  else # :nocov:
123
123
  # Keep this in sync with released Ruby.
124
- warn_syntax_deviation 'parser/ruby32', '3.2.x'
125
- require 'parser/ruby32'
126
- CurrentRuby = Ruby32
124
+ warn_syntax_deviation 'parser/ruby33', '3.3.x'
125
+ require 'parser/ruby33'
126
+ CurrentRuby = Ruby33
127
127
  end
128
128
  end
@@ -5,6 +5,8 @@ module Parser
5
5
 
6
6
  class Lexer::Literal
7
7
  DELIMITERS = { '(' => ')', '[' => ']', '{' => '}', '<' => '>' }
8
+ SPACE = ' '.ord
9
+ TAB = "\t".ord
8
10
 
9
11
  TYPES = {
10
12
  # type start token interpolate?
@@ -234,7 +236,20 @@ module Parser
234
236
  protected
235
237
 
236
238
  def delimiter?(delimiter)
237
- if @indent
239
+ if heredoc?
240
+ # This heredoc is valid:
241
+ # <<~E
242
+ # E
243
+ # and this:
244
+ # <<~E
245
+ # E
246
+ # but this one is not:
247
+ # <<~' E'
248
+ # E
249
+ # because there are not enough leading spaces in the closing delimiter.
250
+ delimiter.end_with?(@end_delim) &&
251
+ delimiter.sub(/#{Regexp.escape(@end_delim)}\z/, '').bytes.all? { |c| c == SPACE || c == TAB }
252
+ elsif @indent
238
253
  @end_delim == delimiter.lstrip
239
254
  else
240
255
  @end_delim == delimiter