diff options
author | Kevin Newton <[email protected]> | 2024-05-31 14:22:45 -0400 |
---|---|---|
committer | git <[email protected]> | 2024-05-31 19:31:52 +0000 |
commit | 47f05dffa1a3cf95fa4a5f2511cd85aeb2341712 (patch) | |
tree | 24d6e4b7dcf4e096e961c20aa0f401ba375cefb3 /lib | |
parent | 02b27aca50c5f58f0f358eeb074a934f7c02da10 (diff) |
[ruby/prism] Match match_hash_var when quotes are used
https://github.com/ruby/prism/commit/f2a327449a
Diffstat (limited to 'lib')
-rw-r--r-- | lib/prism/translation/parser/compiler.rb | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/prism/translation/parser/compiler.rb b/lib/prism/translation/parser/compiler.rb index ca9ac1044e..f8e5eb09fb 100644 --- a/lib/prism/translation/parser/compiler.rb +++ b/lib/prism/translation/parser/compiler.rb @@ -106,14 +106,20 @@ module Prism # ^^^^ def visit_assoc_node(node) if in_pattern + key = node.key + if node.value.is_a?(ImplicitNode) - if node.key.is_a?(SymbolNode) - builder.match_hash_var([node.key.unescaped, srange(node.key.location)]) + if key.is_a?(SymbolNode) + if key.opening.nil? + builder.match_hash_var([key.unescaped, srange(key.location)]) + else + builder.match_hash_var_from_str(token(key.opening_loc), [builder.string_internal([key.unescaped, srange(key.value_loc)])], token(key.closing_loc)) + end else - builder.match_hash_var_from_str(token(node.key.opening_loc), visit_all(node.key.parts), token(node.key.closing_loc)) + builder.match_hash_var_from_str(token(key.opening_loc), visit_all(key.parts), token(key.closing_loc)) end else - builder.pair_keyword([node.key.unescaped, srange(node.key.location)], visit(node.value)) + builder.pair_keyword([key.unescaped, srange(key.location)], visit(node.value)) end elsif node.value.is_a?(ImplicitNode) if (value = node.value.value).is_a?(LocalVariableReadNode) |