Skip to content

Commit 1b40b20

Browse files
committed
Work around constant parsing bug on 1.8
1 parent 9ca29de commit 1b40b20

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

lib/rdoc/parser/ruby.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,9 @@ def parse_class(container, single, tk, comment)
621621
def parse_constant(container, tk, comment)
622622
name = tk.name
623623
skip_tkspace false
624+
625+
return unless name =~ /^\w+$/
626+
624627
eq_tk = get_tk
625628

626629
unless TkASSIGN === eq_tk then

test/test_rdoc_parser_ruby.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -759,6 +759,20 @@ def test_parse_comment_method
759759
assert_equal stream, foo.token_stream
760760
end
761761

762+
def test_parse_constant_attrasgn
763+
util_top_level
764+
765+
klass = @top_level.add_class RDoc::NormalClass, 'Foo'
766+
767+
util_parser "A[k] = v"
768+
769+
tk = @parser.get_tk
770+
771+
@parser.parse_constant klass, tk, ''
772+
773+
assert klass.constants.empty?
774+
end
775+
762776
def test_parse_constant_alias
763777
util_top_level
764778
klass = @top_level.add_class RDoc::NormalClass, 'Foo'

0 commit comments

Comments
 (0)