1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

checker: add type check in interface fields (#9527)

This commit is contained in:
Ned Palacios 2021-03-30 15:32:37 +08:00 committed by GitHub
parent c1d4074bc4
commit 999c385b7f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -362,7 +362,9 @@ pub fn (mut c Checker) interface_decl(decl ast.InterfaceDecl) {
}
for i, field in decl.fields {
c.check_valid_snake_case(field.name, 'field name', field.pos)
c.ensure_type_exists(field.typ, field.pos) or { return }
if field.typ != table.Type(0) {
c.ensure_type_exists(field.typ, field.pos) or { return }
}
for j in 0 .. i {
if field.name == decl.fields[j].name {
c.error('field name `$field.name` duplicate', field.pos)