Skip to content

Commit

Permalink
ast, parser, checker: check struct implements non interface type (fix #…
Browse files Browse the repository at this point in the history
  • Loading branch information
yuyi98 authored Sep 16, 2024
1 parent ca5f47a commit b1ffa4e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions vlib/v/checker/struct.v
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,8 @@ fn (mut c Checker) struct_decl(mut node ast.StructDecl) {
}
}
}
} else {
c.error('`${t_sym.name}` is not an interface type', t.pos)
}
c.type_implements(struct_type, t.typ, node.pos)
}
Expand Down
5 changes: 5 additions & 0 deletions vlib/v/checker/tests/struct_implements_non_interface_err.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
vlib/v/checker/tests/struct_implements_non_interface_err.vv:1:26: error: `Abcde` is not an interface type
1 | struct Walker implements Abcde {
| ~~~~~
2 | aaa string
3 | }
5 changes: 5 additions & 0 deletions vlib/v/checker/tests/struct_implements_non_interface_err.vv
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
struct Walker implements Abcde {
aaa string
}

fn main() {}

0 comments on commit b1ffa4e

Please sign in to comment.