From f4051e0252dc0d620a76e522a2ab9a6233b335c0 Mon Sep 17 00:00:00 2001 From: Joe Conigliaro Date: Fri, 18 Feb 2022 17:54:52 +1100 Subject: [PATCH] checker: make sure generic struct instantiation uses a known type. closes #13506 --- vlib/v/checker/struct.v | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/vlib/v/checker/struct.v b/vlib/v/checker/struct.v index d6adc3119b..01e6b3c81d 100644 --- a/vlib/v/checker/struct.v +++ b/vlib/v/checker/struct.v @@ -130,6 +130,13 @@ pub fn (mut c Checker) struct_init(mut node ast.StructInit) ast.Type { } struct_sym := c.table.sym(node.typ) if struct_sym.info is ast.Struct { + // check if the generic param types have been defined + for ct in struct_sym.info.concrete_types { + ct_sym := c.table.sym(ct) + if ct_sym.kind == .placeholder { + c.error('unknown type `$ct_sym.name`', node.pos) + } + } if struct_sym.info.generic_types.len > 0 && struct_sym.info.concrete_types.len == 0 && !node.is_short_syntax { if c.table.cur_concrete_types.len == 0 {