Project

General

Profile

Bug #15389

9 elements or more larger Hash doesn't show an entry

Added by kou (Kouhei Sutou) almost 2 years ago. Updated almost 2 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
ruby -v:
ruby 2.6.0dev (2018-12-05 trunk 66213) [x86_64-linux]
[ruby-core:90356]

Description

I don't know this problem is a problem of Racc or Ruby itself yet but I'll share this.

Here is a Ruby script that reproduce this case:

require "racc/grammar"

hash = {}
[
  [false, 0],
  [:error, 1],
  [:END, 2],
  [:CLASS, 3],
  [:RULE, 4],
  [:"<", 5],
  [:SYMBOL, 6],
  [:":", 7],
  [:CONV, 8],
].each do |value, ident|
  sym = Racc::Sym.new(value, false)
  sym.ident = ident
  hash[sym] = ident
end
p hash

It outputs the following:

{error=>1, END=>2, CLASS=>3, RULE=>4, <=>5, SYMBOL=>6, :=>7, CONV=>8}

It doesn't have an entry for [false, 0].

If we reduce the last entry ([:CONV, 8]), we can see the entry for [false, 0]:

require "racc/grammar"

hash = {}
[
  [false, 0],
  [:error, 1],
  [:END, 2],
  [:CLASS, 3],
  [:RULE, 4],
  [:"<", 5],
  [:SYMBOL, 6],
  [:":", 7],
].each do |value, ident|
  sym = Racc::Sym.new(value, false)
  sym.ident = ident
  hash[sym] = ident
end
p hash
{$end=>0, error=>1, END=>2, CLASS=>3, RULE=>4, <=>5, SYMBOL=>6, :=>7}

($end=>0 is the entry for [false, 0].)

This is occurred since r65454.

#1

Updated by kou (Kouhei Sutou) almost 2 years ago

  • Subject changed from 8 elements or more larger Hash doesn't show an entry to 9 elements or more larger Hash doesn't show an entry

Updated by Hanmac (Hans Mackowiak) almost 2 years ago

kou (Kouhei Sutou) you need to debug what sym is, it looks like that it thinks that some of them are already existing

it might also be a bad idea to use such objects as hash keys?

Or debug why hash thinks it already has that key?

#3

Updated by nobu (Nobuyoshi Nakada) almost 2 years ago

  • Status changed from Open to Closed

Applied in changeset trunk|r66274.


Adjust reserved hash values

The reserved hash values in hash.c must be consistend with st.c.
[ruby-core:90356] [Bug #15389]

Also available in: Atom PDF