Skip to content

Commit 9f38ee1

Browse files
Earlopainkddnewton
authored andcommitted
[ruby/prism] Fix parser translator ast for empty regex
In that specific case, no string node is emitted ruby/prism@1166db13dd
1 parent a234fd5 commit 9f38ee1

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

lib/prism/translation/parser/compiler.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1512,7 +1512,9 @@ def visit_redo_node(node)
15121512
# ^^^^^
15131513
def visit_regular_expression_node(node)
15141514
parts =
1515-
if node.content.include?("\n")
1515+
if node.content == ""
1516+
[]
1517+
elsif node.content.include?("\n")
15161518
string_nodes_from_line_continuations(node, node.content_loc.start_offset, node.opening)
15171519
else
15181520
[builder.string_internal(token(node.content_loc))]

test/prism/fixtures/regex.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,5 @@ d\\\
5454
e\\
5555
f\
5656
/
57+
58+
//

0 commit comments

Comments
 (0)