[ruby-core:105636] [Ruby master Bug#17719] Irregular evaluation order in hash literals
From:
"jeremyevans0 (Jeremy Evans)" <noreply@...>
Date:
2021-10-14 22:55:52 UTC
List:
ruby-core #105636
Issue #17719 has been updated by jeremyevans0 (Jeremy Evans).
nobu (Nobuyoshi Nakada) wrote in #note-2:
> I think it can be fixed by removing the optimization in the parser and leaving it to the compiler.
I tried the approach of removing the optimization from the parser completely (https://github.com/jeremyevans/ruby/commit/bead10831e4f7ea6fc517fe66796f12579915fb3), but it doesn't handle duplicate keys in keyword arguments, resulting in incorrect unknown keyword errors: https://github.com/jeremyevans/ruby/runs/3900240357#step:15:168
I also tried rebasing your `duplicated-keys-order` branch against master, and that appears to fix the issue. I submitted a pull request for that: https://github.com/ruby/ruby/pull/4969
----------------------------------------
Bug #17719: Irregular evaluation order in hash literals
https://bugs.ruby-lang.org/issues/17719#change-94126
* Author: nobu (Nobuyoshi Nakada)
* Status: Open
* Priority: Normal
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN
----------------------------------------
@mame pointed out an irregular evaluation order example.
```sh
$ ruby -e '{foo:p(1), bar:p(2), foo:p(3)}'
-e:1: warning: key :foo is duplicated and overwritten on line 1
1
3
2
```
It feels like a bug.
https://github.com/nobu/ruby/tree/duplicated-keys-order
Or, probably it would be better to turn into an error?
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>