diff --git a/vlib/v/checker/checker.v b/vlib/v/checker/checker.v index cebd4a5d1f..01a1c49464 100644 --- a/vlib/v/checker/checker.v +++ b/vlib/v/checker/checker.v @@ -497,11 +497,11 @@ fn (mut c Checker) sum_type_decl(node ast.SumTypeDecl) { } else if mut sym.info is ast.Struct { if sym.info.is_generic { if !variant.typ.has_flag(.generic) { - c.error('generic struct `${sym.name}` must specify generic type names, e.g. Foo[T]', + c.error('generic struct `${sym.name}` must specify generic type names, e.g. ${sym.name}[T]', variant.pos) } if node.generic_types.len == 0 { - c.error('generic sumtype `${node.name}` must specify generic type names, e.g. Foo[T]', + c.error('generic sumtype `${node.name}` must specify generic type names, e.g. ${node.name}[T]', node.name_pos) } else { for typ in sym.info.generic_types { diff --git a/vlib/v/checker/containers.v b/vlib/v/checker/containers.v index 5aebb390cb..814390dadc 100644 --- a/vlib/v/checker/containers.v +++ b/vlib/v/checker/containers.v @@ -17,10 +17,10 @@ fn (mut c Checker) array_init(mut node ast.ArrayInit) ast.Type { if elem_info.generic_types.len > 0 && elem_info.concrete_types.len == 0 && !node.elem_type.has_flag(.generic) { if c.table.cur_concrete_types.len == 0 { - c.error('generic struct must specify type parameter, e.g. Foo[int]', + c.error('generic struct `${elem_sym.name}` must specify type parameter, e.g. ${elem_sym.name}[int]', node.elem_type_pos) } else { - c.error('generic struct must specify type parameter, e.g. Foo[T]', + c.error('generic struct `${elem_sym.name}` must specify type parameter, e.g. ${elem_sym.name}[T]', node.elem_type_pos) } } @@ -29,10 +29,10 @@ fn (mut c Checker) array_init(mut node ast.ArrayInit) ast.Type { if elem_info.generic_types.len > 0 && elem_info.concrete_types.len == 0 && !node.elem_type.has_flag(.generic) { if c.table.cur_concrete_types.len == 0 { - c.error('generic interface must specify type parameter, e.g. Foo[int]', + c.error('generic interface `${elem_sym.name}` must specify type parameter, e.g. ${elem_sym.name}[int]', node.elem_type_pos) } else { - c.error('generic interface must specify type parameter, e.g. Foo[T]', + c.error('generic interface `${elem_sym.name}` must specify type parameter, e.g. ${elem_sym.name}[T]', node.elem_type_pos) } } @@ -41,10 +41,10 @@ fn (mut c Checker) array_init(mut node ast.ArrayInit) ast.Type { if elem_info.generic_types.len > 0 && elem_info.concrete_types.len == 0 && !node.elem_type.has_flag(.generic) { if c.table.cur_concrete_types.len == 0 { - c.error('generic sumtype must specify type parameter, e.g. Foo[int]', + c.error('generic sumtype `${elem_sym.name}` must specify type parameter, e.g. ${elem_sym.name}[int]', node.elem_type_pos) } else { - c.error('generic sumtype must specify type parameter, e.g. Foo[T]', + c.error('generic sumtype `${elem_sym.name}` must specify type parameter, e.g. ${elem_sym.name}[T]', node.elem_type_pos) } } @@ -307,10 +307,10 @@ fn (mut c Checker) map_init(mut node ast.MapInit) ast.Type { if val_info.generic_types.len > 0 && val_info.concrete_types.len == 0 && !info.value_type.has_flag(.generic) { if c.table.cur_concrete_types.len == 0 { - c.error('generic struct `${val_sym.name}` must specify type parameter, e.g. Foo[int]', + c.error('generic struct `${val_sym.name}` must specify type parameter, e.g. ${val_sym.name}[int]', node.pos) } else { - c.error('generic struct `${val_sym.name}` must specify type parameter, e.g. Foo[T]', + c.error('generic struct `${val_sym.name}` must specify type parameter, e.g. ${val_sym.name}[T]', node.pos) } } diff --git a/vlib/v/checker/fn.v b/vlib/v/checker/fn.v index 863a2f752a..063b712738 100644 --- a/vlib/v/checker/fn.v +++ b/vlib/v/checker/fn.v @@ -105,7 +105,7 @@ fn (mut c Checker) fn_decl(mut node ast.FnDecl) { gs := c.table.sym(node.return_type) if gs.info is ast.Struct { if gs.info.is_generic && !node.return_type.has_flag(.generic) { - c.error('return generic struct in fn declaration must specify the generic type names, e.g. Foo[T]', + c.error('return generic struct `${gs.name}` in fn declaration must specify the generic type names, e.g. ${gs.name}[T]', node.return_type_pos) } } @@ -224,19 +224,19 @@ fn (mut c Checker) fn_decl(mut node ast.FnDecl) { } if arg_typ_sym.info.generic_types.len > 0 && !param.typ.has_flag(.generic) && arg_typ_sym.info.concrete_types.len == 0 { - c.error('generic struct in fn declaration must specify the generic type names, e.g. Foo[T]', + c.error('generic struct `${arg_typ_sym.name}` in fn declaration must specify the generic type names, e.g. ${arg_typ_sym.name}[T]', param.type_pos) } } else if arg_typ_sym.info is ast.Interface { if arg_typ_sym.info.generic_types.len > 0 && !param.typ.has_flag(.generic) && arg_typ_sym.info.concrete_types.len == 0 { - c.error('generic interface in fn declaration must specify the generic type names, e.g. Foo[T]', + c.error('generic interface `${arg_typ_sym.name}` in fn declaration must specify the generic type names, e.g. ${arg_typ_sym.name}[T]', param.type_pos) } } else if arg_typ_sym.info is ast.SumType { if arg_typ_sym.info.generic_types.len > 0 && !param.typ.has_flag(.generic) && arg_typ_sym.info.concrete_types.len == 0 { - c.error('generic sumtype in fn declaration must specify the generic type names, e.g. Foo[T]', + c.error('generic sumtype `${arg_typ_sym.name}` in fn declaration must specify the generic type names, e.g. ${arg_typ_sym.name}[T]', param.type_pos) } } diff --git a/vlib/v/checker/interface.v b/vlib/v/checker/interface.v index 871c29a93f..3eb318e7c3 100644 --- a/vlib/v/checker/interface.v +++ b/vlib/v/checker/interface.v @@ -211,7 +211,7 @@ fn (mut c Checker) interface_decl(mut node ast.InterfaceDecl) { } } if node.generic_types.len == 0 && has_generic_types { - c.error('generic interface declaration must specify the generic type names, e.g. Foo[T]', + c.error('generic interface `${node.name}` declaration must specify the generic type names, e.g. ${node.name}[T]', node.pos) } } diff --git a/vlib/v/checker/struct.v b/vlib/v/checker/struct.v index a60002c40e..2cd30e62c8 100644 --- a/vlib/v/checker/struct.v +++ b/vlib/v/checker/struct.v @@ -165,7 +165,7 @@ fn (mut c Checker) struct_decl(mut node ast.StructDecl) { } } if node.generic_types.len == 0 && has_generic_types { - c.error('generic struct declaration must specify the generic type names, e.g. Foo[T]', + c.error('generic struct `${node.name}` declaration must specify the generic type names, e.g. ${node.name}[T]', node.pos) } } diff --git a/vlib/v/checker/tests/array_of_generic_struct_init_err.out b/vlib/v/checker/tests/array_of_generic_struct_init_err.out index ed9f2278b9..46d848df9d 100644 --- a/vlib/v/checker/tests/array_of_generic_struct_init_err.out +++ b/vlib/v/checker/tests/array_of_generic_struct_init_err.out @@ -4,7 +4,7 @@ vlib/v/checker/tests/array_of_generic_struct_init_err.vv:6:6: warning: unused va 6 | mut arr := []Item{} | ~~~ 7 | } -vlib/v/checker/tests/array_of_generic_struct_init_err.vv:6:15: error: generic struct must specify type parameter, e.g. Foo[int] +vlib/v/checker/tests/array_of_generic_struct_init_err.vv:6:15: error: generic struct `Item` must specify type parameter, e.g. Item[int] 4 | 5 | fn main() { 6 | mut arr := []Item{} diff --git a/vlib/v/checker/tests/generic_interface_missing_type_names_err.out b/vlib/v/checker/tests/generic_interface_missing_type_names_err.out index 2e7d169fbe..4b2fb6c432 100644 --- a/vlib/v/checker/tests/generic_interface_missing_type_names_err.out +++ b/vlib/v/checker/tests/generic_interface_missing_type_names_err.out @@ -1,4 +1,4 @@ -vlib/v/checker/tests/generic_interface_missing_type_names_err.vv:16:17: error: generic interface must specify type parameter, e.g. Foo[int] +vlib/v/checker/tests/generic_interface_missing_type_names_err.vv:16:17: error: generic interface `Output` must specify type parameter, e.g. Output[int] 14 | 15 | fn main() { 16 | mut outs := []Output{} diff --git a/vlib/v/checker/tests/generic_sumtype_decl_err_a.out b/vlib/v/checker/tests/generic_sumtype_decl_err_a.out index 27b3d622d1..368b71042b 100644 --- a/vlib/v/checker/tests/generic_sumtype_decl_err_a.out +++ b/vlib/v/checker/tests/generic_sumtype_decl_err_a.out @@ -1,4 +1,4 @@ -vlib/v/checker/tests/generic_sumtype_decl_err_a.vv:7:24: error: generic struct `Just` must specify generic type names, e.g. Foo[T] +vlib/v/checker/tests/generic_sumtype_decl_err_a.vv:7:24: error: generic struct `Just` must specify generic type names, e.g. Just[T] 5 | struct Nothing {} 6 | 7 | type Maybe = Nothing | Just diff --git a/vlib/v/checker/tests/generic_sumtype_decl_err_b.out b/vlib/v/checker/tests/generic_sumtype_decl_err_b.out index 9a0403de45..ce95b704d0 100644 --- a/vlib/v/checker/tests/generic_sumtype_decl_err_b.out +++ b/vlib/v/checker/tests/generic_sumtype_decl_err_b.out @@ -1,4 +1,4 @@ -vlib/v/checker/tests/generic_sumtype_decl_err_b.vv:7:6: error: generic sumtype `Maybe` must specify generic type names, e.g. Foo[T] +vlib/v/checker/tests/generic_sumtype_decl_err_b.vv:7:6: error: generic sumtype `Maybe` must specify generic type names, e.g. Maybe[T] 5 | struct Nothing {} 6 | 7 | type Maybe = Nothing | Just[T] diff --git a/vlib/v/checker/tests/generics_fn_arg_type_err.out b/vlib/v/checker/tests/generics_fn_arg_type_err.out index a7d2efff15..f61ac11c91 100644 --- a/vlib/v/checker/tests/generics_fn_arg_type_err.out +++ b/vlib/v/checker/tests/generics_fn_arg_type_err.out @@ -1,4 +1,4 @@ -vlib/v/checker/tests/generics_fn_arg_type_err.vv:14:23: error: generic interface in fn declaration must specify the generic type names, e.g. Foo[T] +vlib/v/checker/tests/generics_fn_arg_type_err.vv:14:23: error: generic interface `List` in fn declaration must specify the generic type names, e.g. List[T] 12 | } 13 | 14 | fn do_list_thing(list List) { // <--- Error here diff --git a/vlib/v/checker/tests/generics_fn_return_generic_struct_err.out b/vlib/v/checker/tests/generics_fn_return_generic_struct_err.out index 2d1b4f8ed7..47cb85524e 100644 --- a/vlib/v/checker/tests/generics_fn_return_generic_struct_err.out +++ b/vlib/v/checker/tests/generics_fn_return_generic_struct_err.out @@ -1,4 +1,4 @@ -vlib/v/checker/tests/generics_fn_return_generic_struct_err.vv:13:32: error: return generic struct in fn declaration must specify the generic type names, e.g. Foo[T] +vlib/v/checker/tests/generics_fn_return_generic_struct_err.vv:13:32: error: return generic struct `GenericChannelStruct` in fn declaration must specify the generic type names, e.g. GenericChannelStruct[T] 11 | } 12 | 13 | pub fn new_channel_struct[T]() GenericChannelStruct { diff --git a/vlib/v/checker/tests/generics_interface_declaration_err.out b/vlib/v/checker/tests/generics_interface_declaration_err.out index 879277f795..b2a509fbcd 100644 --- a/vlib/v/checker/tests/generics_interface_declaration_err.out +++ b/vlib/v/checker/tests/generics_interface_declaration_err.out @@ -1,4 +1,4 @@ -vlib/v/checker/tests/generics_interface_declaration_err.vv:1:1: error: generic interface declaration must specify the generic type names, e.g. Foo[T] +vlib/v/checker/tests/generics_interface_declaration_err.vv:1:1: error: generic interface `Expr` declaration must specify the generic type names, e.g. Expr[T] 1 | interface Expr { | ~~~~~~~~~~~~~~~~ 2 | accept(v Visitor) R diff --git a/vlib/v/checker/tests/generics_method_receiver_type_err.out b/vlib/v/checker/tests/generics_method_receiver_type_err.out index bd03e25e10..9f038bc29f 100644 --- a/vlib/v/checker/tests/generics_method_receiver_type_err.out +++ b/vlib/v/checker/tests/generics_method_receiver_type_err.out @@ -1,4 +1,4 @@ -vlib/v/checker/tests/generics_method_receiver_type_err.vv:6:11: error: generic struct in fn declaration must specify the generic type names, e.g. Foo[T] +vlib/v/checker/tests/generics_method_receiver_type_err.vv:6:11: error: generic struct `Node` in fn declaration must specify the generic type names, e.g. Node[T] 4 | } 5 | 6 | pub fn (x Node) str() string { diff --git a/vlib/v/checker/tests/generics_struct_declaration_err.out b/vlib/v/checker/tests/generics_struct_declaration_err.out index eb8063f62d..c47eadf4c2 100644 --- a/vlib/v/checker/tests/generics_struct_declaration_err.out +++ b/vlib/v/checker/tests/generics_struct_declaration_err.out @@ -1,4 +1,4 @@ -vlib/v/checker/tests/generics_struct_declaration_err.vv:5:1: error: generic struct declaration must specify the generic type names, e.g. Foo[T] +vlib/v/checker/tests/generics_struct_declaration_err.vv:5:1: error: generic struct `MyGenericChannelStruct` declaration must specify the generic type names, e.g. MyGenericChannelStruct[T] 3 | } 4 | 5 | struct MyGenericChannelStruct { diff --git a/vlib/v/checker/tests/map_of_generic_struct_init_err.out b/vlib/v/checker/tests/map_of_generic_struct_init_err.out index 5ec3cc25ad..c16c7751e9 100644 --- a/vlib/v/checker/tests/map_of_generic_struct_init_err.out +++ b/vlib/v/checker/tests/map_of_generic_struct_init_err.out @@ -4,7 +4,7 @@ vlib/v/checker/tests/map_of_generic_struct_init_err.vv:6:6: warning: unused vari 6 | mut m := map[string]Item{} | ^ 7 | } -vlib/v/checker/tests/map_of_generic_struct_init_err.vv:6:11: error: generic struct `Item` must specify type parameter, e.g. Foo[int] +vlib/v/checker/tests/map_of_generic_struct_init_err.vv:6:11: error: generic struct `Item` must specify type parameter, e.g. Item[int] 4 | 5 | fn main() { 6 | mut m := map[string]Item{}