Actions
Bug #15389
closed9 elements or more larger Hash doesn't show an entry
Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.6.0dev (2018-12-05 trunk 66213) [x86_64-linux]
Backport:
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.
Updated by kou (Kouhei Sutou) about 6 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) about 6 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?
Updated by nobu (Nobuyoshi Nakada) about 6 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]
Actions
Like0
Like0Like0Like0