Skip to content

Commit 2772846

Browse files
authored
Merge pull request #469 from aycabta/fix-dynamic-string-detection
Handle "#{}" as dynamic string
2 parents 53f146a + e2fa6a8 commit 2772846

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

lib/rdoc/ruby_lex.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1250,8 +1250,8 @@ def identify_string(ltype, quoted = ltype, type = nil)
12501250
break
12511251
elsif @ltype != "'" && @ltype != "]" && @ltype != ":" and ch == "#"
12521252
ch = getc
1253-
subtype = true
12541253
if ch == "{" then
1254+
subtype = true
12551255
str << ch << skip_inner_expression
12561256
next
12571257
else

test/test_rdoc_parser_ruby.rb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2063,7 +2063,7 @@ def test_parse_statements_class_nested
20632063
end
20642064

20652065
def test_parse_statements_def_percent_string_pound
2066-
util_parser "class C\ndef a\n%r{#}\nend\ndef b() end\nend"
2066+
util_parser "class C\ndef a\n%r{#}\n%r{\#{}}\nend\ndef b() end\nend"
20672067

20682068
@parser.parse_statements @top_level, RDoc::Parser::Ruby::NORMAL
20692069

@@ -2080,9 +2080,11 @@ def test_parse_statements_def_percent_string_pound
20802080
tk(:SPACE, 11, 2, 3, nil, ' '),
20812081
tk(:IDENTIFIER, 12, 2, 4, 'a', 'a'),
20822082
tk(:NL, 13, 2, 5, nil, "\n"),
2083-
tk(:DREGEXP, 14, 3, 0, nil, '%r{#}'),
2083+
tk(:REGEXP, 14, 3, 0, nil, '%r{#}'),
20842084
tk(:NL, 19, 3, 5, nil, "\n"),
2085-
tk(:END, 20, 4, 0, 'end', 'end'),
2085+
tk(:DREGEXP, 20, 4, 0, nil, '%r{#{}}'),
2086+
tk(:NL, 27, 4, 7, nil, "\n"),
2087+
tk(:END, 28, 5, 0, 'end', 'end'),
20862088
]
20872089

20882090
assert_equal expected, a.token_stream

0 commit comments

Comments
 (0)