Skip to content
Open
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
9 changes: 9 additions & 0 deletions spec/parser_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,15 @@ describe Parser do
fields.first.type.should eq(PointerType.new(UnexposedType.new("foo")))
end

it "parses struct with unexposed enum" do
nodes = parse("struct point { enum { x, y } foo; };")
type = nodes.last.as(StructOrUnion)
fields = type.fields
node_ref = fields.first.type.as(NodeRef)
enum_def = node_ref.node.as(CrystalLib::Enum)
enum_def.values.size.should eq(2)
end

it "parses recursive struct" do
nodes = parse("struct point { struct point* x; };")
type = nodes.last.as(StructOrUnion)
Expand Down
2 changes: 2 additions & 0 deletions src/crystal_lib/parser.cr
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,8 @@ class CrystalLib::Parser
NodeRef.new(visit_struct_or_union_declaration(definition, :struct))
when .union_decl?
NodeRef.new(visit_struct_or_union_declaration(definition, :union))
when .enum_decl?
NodeRef.new(visit_enum_declaration(definition))
else
UnexposedType.new(type.cursor.spelling)
end
Expand Down