rbs 4.2.0
class Foo
def bar; end
# @rbs @a: Integer
X = 1
end
RBS::InlineParser.parse reports UnusedInlineAnnotation for @rbs @a: Integer and no InstanceVariableMember is created. Moving the annotation above def bar makes it work.
Cause: InlineParser#visit_class_or_module_body calls comments.each_enclosed_block(child_node) on the body StatementsNode (whose line range spans from the first member to the last) and reports every block inside it as unused, before the class-level each_enclosed_block(node) that handles InstanceVariableAnnotation runs. Only blocks located before the first member survive.
https://github.com/ruby/rbs/blob/v4.2.0/lib/rbs/inline_parser.rb (visit_class_or_module_body)
rbs 4.2.0
RBS::InlineParser.parsereportsUnusedInlineAnnotationfor@rbs @a: Integerand noInstanceVariableMemberis created. Moving the annotation abovedef barmakes it work.Cause:
InlineParser#visit_class_or_module_bodycallscomments.each_enclosed_block(child_node)on the bodyStatementsNode(whose line range spans from the first member to the last) and reports every block inside it as unused, before the class-leveleach_enclosed_block(node)that handlesInstanceVariableAnnotationruns. Only blocks located before the first member survive.https://github.com/ruby/rbs/blob/v4.2.0/lib/rbs/inline_parser.rb (
visit_class_or_module_body)