diff options
author | Aaron Patterson <tenderlove@ruby-lang.org> | 2023-12-07 16:37:24 -0800 |
---|---|---|
committer | git <svn-admin@ruby-lang.org> | 2023-12-08 14:35:26 +0000 |
commit | 0166040939fd9057a7fb724e290fbe6c9cc036c2 (patch) | |
tree | 8854bd740291bb3cc1640c31e9072370e8bcdafc /prism | |
parent | 892b5f10d52bacaf8c6b430d0e9a95dc0ea36834 (diff) |
[ruby/prism] Hashes need to deoptimize based on their contents
If a hash has children that are not "basic" types of objects, then we
can't consider the hash to be a static literal.
Fixes: #2015
https://github.com/ruby/prism/commit/ca2523137d
Diffstat (limited to 'prism')
-rw-r--r-- | prism/prism.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/prism/prism.c b/prism/prism.c index 6f2f37113b..ca9430f6ca 100644 --- a/prism/prism.c +++ b/prism/prism.c @@ -3272,7 +3272,7 @@ pm_hash_node_elements_append(pm_hash_node_t *hash, pm_node_t *element) { // If the element is not a static literal, then the hash is not a static // literal. Turn that flag off. - if ((element->flags & PM_NODE_FLAG_STATIC_LITERAL) == 0) { + if (PM_NODE_TYPE_P(element, PM_ARRAY_NODE) || PM_NODE_TYPE_P(element, PM_HASH_NODE) || PM_NODE_TYPE_P(element, PM_RANGE_NODE) || (element->flags & PM_NODE_FLAG_STATIC_LITERAL) == 0) { hash->base.flags &= (pm_node_flags_t) ~PM_NODE_FLAG_STATIC_LITERAL; } } |