parser 3.2.2.0 → 3.2.2.1

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: acb834a9f7eaf9945e03a97144a82e998ececdec410075e43d40f675c68f38a7
4
- data.tar.gz: ef0d2ebb2fc7f3f82e7c59a9110f0028519ab72e68683f6b247df18a06392975
3
+ metadata.gz: 8675f26d1fb8a457da79bb3f675a57647eefdefec8bf05d75bf97677e20860b0
4
+ data.tar.gz: fe0759d1f51da6d85b89b5cc9d1fb34a4493f2c58e71cef9598753b9643b2a0a
5
5
  SHA512:
6
- metadata.gz: 8ea6acca7f134f387381d5df2247c428208258a5d0ec0f61107ebeab11503a8f1c42edf9a00a48765913da72a59725e82b192d60d41cbff58611c55005315e19
7
- data.tar.gz: 5632573f7f13c036f083a1494ecb449830fc27aad1f24d25d12162e4d5b4562a09042338c12c2d85b513283e0871484c88c519db77916a1dc8730e5227f7ef49
6
+ metadata.gz: 2271cfa20f5c8bd349e8465f0b5f4f667309c410ec7f622ec330e28adf4b896b560e0ce2f744bc267b6a7e4be687dfe351599660b200487de5ef9a7f2317121c
7
+ data.tar.gz: 86e4b5e6368f0857ebeed00fafd2fb9ff274288602458aff86eac29324fa743c5acf4d3d5e45e0ea767b2501ec315888ef37b154d8c75069826b02631320f31d
@@ -538,34 +538,23 @@ module Parser
538
538
  end
539
539
 
540
540
  def associate(begin_t, pairs, end_t)
541
- 0.upto(pairs.length - 1) do |i|
542
- (i + 1).upto(pairs.length - 1) do |j|
543
- pair_i = pairs[i]
544
- pair_j = pairs[j]
541
+ key_set = Set.new
545
542
 
546
- next if pair_i.type != :pair || pair_j.type != :pair
543
+ pairs.each do |pair|
544
+ next unless pair.type.eql?(:pair)
547
545
 
548
- key1, = *pair_i
549
- key2, = *pair_j
546
+ key, = *pair
550
547
 
551
- do_warn = false
552
-
553
- # keys have to be simple nodes, MRI ignores equal composite keys like
554
- # `{ a(1) => 1, a(1) => 1 }`
555
- case key1.type
556
- when :sym, :str, :int, :float
557
- if key1 == key2
558
- do_warn = true
559
- end
560
- when :rational, :complex, :regexp
561
- if @parser.version >= 31 && key1 == key2
562
- do_warn = true
563
- end
564
- end
548
+ case key.type
549
+ when :sym, :str, :int, :float
550
+ when :rational, :complex, :regexp
551
+ next unless @parser.version >= 31
552
+ else
553
+ next
554
+ end
565
555
 
566
- if do_warn
567
- diagnostic :warning, :duplicate_hash_key, nil, key2.loc.expression
568
- end
556
+ unless key_set.add?(key)
557
+ diagnostic :warning, :duplicate_hash_key, nil, key.loc.expression
569
558
  end
570
559
  end
571
560