v.checker: turn `interface field ... must be initialized` to a notice temporarily

pull/11156/head
Delyan Angelov 2021-08-11 16:32:09 +03:00
parent 9d4d0a9894
commit a64a4d932c
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
3 changed files with 18 additions and 6 deletions

View File

@ -1175,8 +1175,8 @@ pub fn (mut c Checker) struct_init(mut node ast.StructInit) ast.Type {
// Do not allow empty uninitialized interfaces
sym := c.table.get_type_symbol(field.typ)
if sym.kind == .interface_ {
// TODO error
c.warn('interface field `${type_sym.name}.$field.name` must be initialized',
// TODO: should be an error instead, but first `ui` needs updating.
c.note('interface field `${type_sym.name}.$field.name` must be initialized',
node.pos)
}
// Do not allow empty uninitialized sum types

View File

@ -1,3 +1,15 @@
vlib/v/checker/tests/import_symbol_private_err.vv:11:6: notice: interface field `io.ReaderWriterImpl.r` must be initialized
9 | since(now())
10 | _ = {'h': 2}.exists('h')
11 | _ = ReaderWriterImpl{}
| ~~~~~~~~~~~~~~~~~~
12 | }
vlib/v/checker/tests/import_symbol_private_err.vv:11:6: notice: interface field `io.ReaderWriterImpl.w` must be initialized
9 | since(now())
10 | _ = {'h': 2}.exists('h')
11 | _ = ReaderWriterImpl{}
| ~~~~~~~~~~~~~~~~~~
12 | }
vlib/v/checker/tests/import_symbol_private_err.vv:3:20: error: module `time` function `since()` is private
1 | import v.scanner
2 | import v.parser

View File

@ -1,4 +1,4 @@
vlib/v/checker/tests/interface_init_err.vv:15:7: error: interface field `Server.handler` must be initialized
vlib/v/checker/tests/interface_init_err.vv:15:7: notice: interface field `Server.handler` must be initialized
13 |
14 | fn main() {
15 | _ := Server{}