[ruby/prism] Match match_hash_var when quotes are used
https://github.com/ruby/prism/commit/f2a327449a
This commit is contained in:
parent
02b27aca50
commit
47f05dffa1
@ -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)
|
||||
|
@ -83,7 +83,6 @@ module Prism
|
||||
"unparser/corpus/semantic/dstr.txt",
|
||||
"whitequark/dedenting_interpolating_heredoc_fake_line_continuation.txt",
|
||||
"whitequark/masgn_nested.txt",
|
||||
"whitequark/newline_in_hash_argument.txt",
|
||||
"whitequark/parser_bug_640.txt",
|
||||
"whitequark/parser_slash_slash_n_escaping_in_literals.txt",
|
||||
"whitequark/ruby_bug_11989.txt",
|
||||
@ -167,6 +166,7 @@ module Prism
|
||||
"whitequark/interp_digit_var.txt",
|
||||
"whitequark/lbrace_arg_after_command_args.txt",
|
||||
"whitequark/multiple_pattern_matches.txt",
|
||||
"whitequark/newline_in_hash_argument.txt",
|
||||
"whitequark/parser_drops_truncated_parts_of_squiggly_heredoc.txt",
|
||||
"whitequark/ruby_bug_11990.txt",
|
||||
"whitequark/ruby_bug_14690.txt",
|
||||
@ -215,7 +215,7 @@ module Prism
|
||||
assert_equal_tokens(expected_tokens, actual_tokens) if compare_tokens
|
||||
assert_equal_comments(expected_comments, actual_comments) if compare_comments
|
||||
elsif compare_asts
|
||||
flunk "expected: #{expected_ast.inspect}\nactual: #{actual_ast.inspect}"
|
||||
assert_equal expected_ast, actual_ast, -> { assert_equal_asts_message(expected_ast, actual_ast) }
|
||||
end
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user