[ruby-core:117640] [Ruby master Bug#20442] Printing class variable inconsistent when using nested hashes
From:
"k776 (Kieran Pilkington) via ruby-core" <ruby-core@...>
Date:
2024-04-22 06:09:17 UTC
List:
ruby-core #117640
Issue #20442 has been reported by k776 (Kieran Pilkington).
----------------------------------------
Bug #20442: Printing class variable inconsistent when using nested hashes
https://bugs.ruby-lang.org/issues/20442
* Author: k776 (Kieran Pilkington)
* Status: Open
* ruby -v: 3.3.0
* Backport: 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN
----------------------------------------
See attached test.rb. I have a class with a class variable. The idea is simple, increment the value and then print out the resulting class var.
```
Mock1
0
1
Mock2
{}
{"a"=>1}
Mock3
{}
{"a"=>1}
Mock4
{}
{}
```
Mock1 through Mock3 are working as expected. But Mock4 does not, it outputs a blank hash, rather than the expected: `{"a"=>{"a"=>1}}`
The value is being set. If I replace the print method with `@val['a']['a']` is outputs the number 1 as expected.
---Files--------------------------------
test.rb (820 Bytes)
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/