diff --git a/compiler/__tests__/parser.test.ts b/compiler/__tests__/parser.test.ts index c3985ac..8f2196c 100644 --- a/compiler/__tests__/parser.test.ts +++ b/compiler/__tests__/parser.test.ts @@ -884,4 +884,37 @@ speck Second { } }); }); + + // Cycle 73: List fields in interface records must be preserved in the AST. + // Previously the generator emitted empty type for these fields because + // it called speckTypeToProto(f.type.name) which returns '' when .name is + // undefined (List/Map/Set nodes use .elementType/.keyType/.valueType, + // not .name). The generator was fixed, but this test locks in the parser + // behavior so a regression is caught early. + describe('List in interface record fields (cycle 73)', () => { + it('should parse List fields in interface records', () => { + const content = `speck One { + interface Container { + items: List, + names: List + } + interface Ticket { + id: String + } +}`; + const ast = parseSpeckContent(content); + const iface = ast.specks[0].members.find(m => m.name === 'Container'); + expect(iface).toBeDefined(); + if (iface?.type === 'interface') { + expect(iface.fields).toBeDefined(); + expect(iface.fields.length).toBe(2); + expect(iface.fields[0].name).toBe('items'); + expect(iface.fields[0].type.type).toBe('list'); + expect(iface.fields[0].type.elementType?.name).toBe('Ticket'); + expect(iface.fields[1].name).toBe('names'); + expect(iface.fields[1].type.type).toBe('list'); + expect(iface.fields[1].type.elementType?.name).toBe('String'); + } + }); + }); });