From: hanmac@gmx.de
To: ruby-core@ruby-lang.org
Subject: [ruby-core:90362] [Ruby trunk Bug#15389] 9 elements or more larger Hash doesn't show an entry
Date: Fri, 07 Dec 2018 09:30:45 +0000 (UTC) [thread overview]
Message-ID: <redmine.journal-75473.20181207093043.144c29861a8c0882@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-15389.20181207042515@ruby-lang.org
Issue #15389 has been updated by Hanmac (Hans Mackowiak).
@kou 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?
----------------------------------------
Bug #15389: 9 elements or more larger Hash doesn't show an entry
https://bugs.ruby-lang.org/issues/15389#change-75473
* Author: kou (Kouhei Sutou)
* Status: Open
* Priority: Normal
* Assignee:
* Target version:
* ruby -v: ruby 2.6.0dev (2018-12-05 trunk 66213) [x86_64-linux]
* Backport: 2.4: UNKNOWN, 2.5: UNKNOWN
----------------------------------------
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:
```ruby
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:
```text
{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]`:
```ruby
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
```
```text
{$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.
--
https://bugs.ruby-lang.org/
prev parent reply other threads:[~2018-12-07 9:30 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <redmine.issue-15389.20181207042515@ruby-lang.org>
2018-12-07 4:25 ` [ruby-core:90356] [Ruby trunk Bug#15389] 8 elements or more larger Hash doesn't show an entry kou
2018-12-07 9:30 ` hanmac [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.ruby-lang.org/en/community/mailing-lists/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=redmine.journal-75473.20181207093043.144c29861a8c0882@ruby-lang.org \
--to=ruby-core@ruby-lang.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).