Skip to content

Commit 8c92d16

Browse files
committed
Add singleton methods separately to prevent infinite loop.
1 parent 07c9e86 commit 8c92d16

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

lib/rdoc/parser/ruby.rb

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,7 @@ def lex_init()
700700
ch = getc
701701
if @lex_state == EXPR_ARG && ch !~ /\s/
702702
ungetc
703-
@lex_state = EXPR_BEG;
703+
@lex_state = EXPR_BEG
704704
Token(TkQUESTION).set_text(op)
705705
else
706706
str = op
@@ -788,7 +788,7 @@ def lex_int2
788788
@lex_state = EXPR_BEG
789789
tk = Token(TkCOLON)
790790
else
791-
@lex_state = EXPR_FNAME;
791+
@lex_state = EXPR_FNAME
792792
tk = Token(TkSYMBEG)
793793
end
794794
tk.set_text(":")
@@ -2057,7 +2057,7 @@ def parse_meta_method(container, single, tk, comment)
20572057
name = 'unknown'
20582058
end
20592059
end
2060-
2060+
20612061
meth = RDoc::MetaMethod.new get_tkread, name
20622062
meth.singleton = singleton
20632063

@@ -2572,7 +2572,8 @@ def parse_visibility(container, single, tk)
25722572
when 'module_function' then
25732573
singleton = true
25742574
:public
2575-
else raise "Invalid visibility: #{tk.name}"
2575+
else
2576+
raise "Invalid visibility: #{tk.name}"
25762577
end
25772578

25782579
skip_tkspace_comment false
@@ -2590,18 +2591,22 @@ def parse_visibility(container, single, tk)
25902591
args = parse_symbol_arg
25912592
container.set_visibility_for args, :private, false
25922593

2594+
module_functions = []
2595+
25932596
container.methods_matching args do |m|
25942597
s_m = m.dup
2598+
s_m.singleton = true if RDoc::AnyMethod === s_m
2599+
s_m.visibility = :public
2600+
module_functions << s_m
2601+
end
25952602

2603+
module_functions.each do |s_m|
25962604
case s_m
25972605
when RDoc::AnyMethod then
25982606
container.add_method s_m
25992607
when RDoc::Attr then
2600-
container.add_attr s_m
2608+
container.add_attribute s_m
26012609
end
2602-
2603-
s_m.singleton = true
2604-
s_m.visibility = :public
26052610
end
26062611
else
26072612
args = parse_symbol_arg

0 commit comments

Comments
 (0)