diff options
author | Kevin Newton <kddnewton@gmail.com> | 2024-03-06 15:59:43 -0500 |
---|---|---|
committer | git <svn-admin@ruby-lang.org> | 2024-03-06 21:37:26 +0000 |
commit | 4b5fc916172b167970e5af6cdec5d1541ca26b41 (patch) | |
tree | eda2d2e85ee6d1d96f9518cce6ec656b71a15b21 /lib/prism/translation/parser | |
parent | 38a4b5c1fad4790c8170112e9a97bf165b48cdbd (diff) |
[ruby/prism] Fix implicit local variables in hashes
https://github.com/ruby/prism/commit/05e0c6792c
Diffstat (limited to 'lib/prism/translation/parser')
-rw-r--r-- | lib/prism/translation/parser/compiler.rb | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/prism/translation/parser/compiler.rb b/lib/prism/translation/parser/compiler.rb index e54ee1dbf5..4ca706c764 100644 --- a/lib/prism/translation/parser/compiler.rb +++ b/lib/prism/translation/parser/compiler.rb @@ -116,7 +116,14 @@ module Prism builder.pair_keyword([node.key.unescaped, srange(node.key.location)], visit(node.value)) end elsif node.value.is_a?(ImplicitNode) - builder.pair_label([node.key.unescaped, srange(node.key.location)]) + if (value = node.value.value).is_a?(LocalVariableReadNode) + builder.pair_keyword( + [node.key.unescaped, srange(node.key)], + builder.ident([value.name, srange(node.key.value_loc)]).updated(:lvar) + ) + else + builder.pair_label([node.key.unescaped, srange(node.key.location)]) + end elsif node.operator_loc builder.pair(visit(node.key), token(node.operator_loc), visit(node.value)) elsif node.key.is_a?(SymbolNode) && node.key.opening_loc.nil? |