Skip to content

Commit beed439

Browse files
committed
Use correct opening and closing parenthesis for array pattern in parser
1 parent f2a3274 commit beed439

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

lib/prism/translation/parser/compiler.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,11 @@ def visit_array_pattern_node(node)
9090
end
9191

9292
if node.constant
93-
builder.const_pattern(visit(node.constant), token(node.opening_loc), builder.array_pattern(nil, visited, nil), token(node.closing_loc))
93+
if visited.empty?
94+
builder.const_pattern(visit(node.constant), token(node.opening_loc), builder.array_pattern(token(node.opening_loc), visited, token(node.closing_loc)), token(node.closing_loc))
95+
else
96+
builder.const_pattern(visit(node.constant), token(node.opening_loc), builder.array_pattern(nil, visited, nil), token(node.closing_loc))
97+
end
9498
else
9599
builder.array_pattern(token(node.opening_loc), visited, token(node.closing_loc))
96100
end

test/prism/ruby/parser_test.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ class ParserTest < TestCase
5959
"seattlerb/block_decomp_splat.txt",
6060
"seattlerb/block_paren_splat.txt",
6161
"seattlerb/bug190.txt",
62-
"seattlerb/case_in.txt",
6362
"seattlerb/heredoc_nested.txt",
6463
"seattlerb/heredoc_squiggly_blank_line_plus_interpolation.txt",
6564
"seattlerb/heredoc_with_carriage_return_escapes_windows.txt",
@@ -69,7 +68,6 @@ class ParserTest < TestCase
6968
"seattlerb/heredoc_with_only_carriage_returns.txt",
7069
"seattlerb/masgn_double_paren.txt",
7170
"seattlerb/parse_line_heredoc_hardnewline.txt",
72-
"seattlerb/parse_pattern_044.txt",
7371
"seattlerb/pct_nl.txt",
7472
"seattlerb/pctW_lineno.txt",
7573
"seattlerb/regexp_esc_C_slash.txt",
@@ -108,6 +106,7 @@ class ParserTest < TestCase
108106
"xstring_with_backslash.txt",
109107
"seattlerb/backticks_interpolation_line.txt",
110108
"seattlerb/bug169.txt",
109+
"seattlerb/case_in.txt",
111110
"seattlerb/class_comments.txt",
112111
"seattlerb/difficult4__leading_dots2.txt",
113112
"seattlerb/difficult6__7.txt",

0 commit comments

Comments
 (0)