Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -3789,7 +3789,7 @@ static bool parse_inline_leading_annotation(rbs_parser_t *parser, rbs_ast_ruby_a
rbs_location_t *colon_loc = rbs_location_new(ALLOCATOR(), colon_range);

rbs_node_t *type = NULL;
if (!rbs_parse_type(parser, &type, false, false)) {
if (!rbs_parse_type(parser, &type, false, true)) {
return false;
}

Expand Down
15 changes: 11 additions & 4 deletions test/rbs/inline_annotation_parsing_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,17 @@ def test_parse__instance_variable
assert_equal "Array[String]", annot.type.location.source
assert_nil annot.comment_location
end

Parser.parse_inline_leading_annotation("@rbs @self: self", 0...).tap do |annot|
assert_instance_of AST::Ruby::Annotations::InstanceVariableAnnotation, annot
assert_equal "@rbs @self: self", annot.location.source
assert_equal "@rbs", annot.prefix_location.source
assert_equal "@self", annot.ivar_name_location.source
assert_equal :@self, annot.ivar_name
assert_equal ":", annot.colon_location.source
assert_equal "self", annot.type.location.source
assert_nil annot.comment_location
end
end

def test_error__instance_variable
Expand All @@ -208,9 +219,5 @@ def test_error__instance_variable
assert_raises RBS::ParsingError do
Parser.parse_inline_leading_annotation("@rbs @name: void", 0...)
end

assert_raises RBS::ParsingError do
Parser.parse_inline_leading_annotation("@rbs @name: self", 0...)
end
end
end
Loading