Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

checker: fix missing error for non initialized interface struct member #18733

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions vlib/v/checker/struct.v
Original file line number Diff line number Diff line change
Expand Up @@ -672,8 +672,7 @@ fn (mut c Checker) struct_init(mut node ast.StructInit, is_field_zero_struct_ini
}
if !field.typ.has_flag(.option) && sym.kind == .interface_
&& (!has_noinit && sym.language != .js) && !node.has_update_expr {
// TODO: should be an error instead, but first `ui` needs updating.
c.note('interface field `${type_sym.name}.${field.name}` must be initialized',
c.error('interface field `${type_sym.name}.${field.name}` must be initialized',
node.pos)
}
// Do not allow empty uninitialized sum types
Expand Down
2 changes: 1 addition & 1 deletion vlib/v/checker/tests/interface_init_err.out
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
vlib/v/checker/tests/interface_init_err.vv:15:7: notice: interface field `Server.handler` must be initialized
vlib/v/checker/tests/interface_init_err.vv:15:7: error: interface field `Server.handler` must be initialized
13 |
14 | fn main() {
15 | _ := Server{}
Expand Down
Loading