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

pull/9531/head
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
1 changed files with 3 additions and 1 deletions

View File

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