Skip to content

Commit

Permalink
checker: more precise error message
Browse files Browse the repository at this point in the history
  • Loading branch information
medvednikov committed Oct 3, 2023
1 parent 6b79b2a commit b1f141a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion vlib/v/checker/struct.v
Expand Up @@ -572,7 +572,8 @@ fn (mut c Checker) struct_init(mut node ast.StructInit, is_field_zero_struct_ini
}
if exp_type_sym.kind == .voidptr && got_type_sym.kind == .struct_
&& !got_type.is_ptr() {
c.error('allocate on the heap for use in other functions', init_field.pos)
c.error('allocate `${got_type_sym.name}` on the heap for use in other functions',
init_field.pos)
}
if exp_type_sym.kind == .array && got_type_sym.kind == .array {
if init_field.expr is ast.IndexExpr
Expand Down
@@ -1,4 +1,4 @@
vlib/v/checker/tests/struct_voidptr_field_no_ptr_struct_value_err.vv:11:3: error: allocate on the heap for use in other functions
vlib/v/checker/tests/struct_voidptr_field_no_ptr_struct_value_err.vv:11:3: error: allocate `Foo` on the heap for use in other functions
9 | fn main() {
10 | _ := Foo2{
11 | a: Foo{}
Expand Down

0 comments on commit b1f141a

Please sign in to comment.