diff --git a/spec/parser_spec.cr b/spec/parser_spec.cr index 7610165..4336123 100644 --- a/spec/parser_spec.cr +++ b/spec/parser_spec.cr @@ -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) diff --git a/src/crystal_lib/parser.cr b/src/crystal_lib/parser.cr index e3f2914..4964877 100644 --- a/src/crystal_lib/parser.cr +++ b/src/crystal_lib/parser.cr @@ -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