Skip to content

Commit

Permalink
improve error pos
Browse files Browse the repository at this point in the history
  • Loading branch information
Delta456 committed Jul 20, 2024
1 parent 051753d commit 3428257
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion vlib/v/checker/checker.v
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,7 @@ fn (mut c Checker) alias_type_decl(node ast.AliasTypeDecl) {
for field in parent_typ_sym.info.fields {
if c.table.final_sym(field.typ).kind != .struct_ {
c.error('cannot embed non-struct `${c.table.sym(field.typ).name}`',
node.type_pos)
field.type_pos)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,9 @@ vlib/v/checker/tests/type_alias_decl_anon_struct_invalid_embed.vv:2:16: error: c
| ~~~~~~~~
3 | Int
4 | }
vlib/v/checker/tests/type_alias_decl_anon_struct_invalid_embed.vv:3:2: error: cannot embed non-struct `Int`
1 | type Int = int
2 | type MyIndex = struct {
3 | Int
| ~~~
4 | }
4 changes: 2 additions & 2 deletions vlib/v/parser/tests/struct_anon_invalid_embed_err.out
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
vlib/v/parser/tests/struct_anon_invalid_embed_err.vv:2:16: error: cannot embed non-struct `Int`
vlib/v/parser/tests/struct_anon_invalid_embed_err.vv:3:6: error: cannot embed non-struct `Int`
1 | type Int = int
2 | type MyIndex = struct {
| ~~~~~~~~
3 | Int Int
| ~~~
4 | }

0 comments on commit 3428257

Please sign in to comment.