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

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

This commit is contained in:
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
@ -10,10 +22,10 @@ vlib/v/checker/tests/import_symbol_private_err.vv:4:13: error: module `io` type
3 | import time { now, since }
4 | import io { ReaderWriterImpl }
| ~~~~~~~~~~~~~~~~
5 |
5 |
6 | fn main() {
vlib/v/checker/tests/import_symbol_private_err.vv:7:18: error: constant `v.scanner.single_quote` is private
5 |
5 |
6 | fn main() {
7 | println(scanner.single_quote)
| ~~~~~~~~~~~~
@ -45,4 +57,4 @@ vlib/v/checker/tests/import_symbol_private_err.vv:11:6: error: type `io.ReaderWr
10 | _ = {'h': 2}.exists('h')
11 | _ = ReaderWriterImpl{}
| ~~~~~~~~~~~~~~~~~~
12 | }
12 | }

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{}