Skip to content

Commit e738d67

Browse files
authored
checker: fix [noinit] attr checking with multiple attr (#18079)
1 parent e8df5a7 commit e738d67

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

vlib/v/checker/struct.v

+1-1
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ fn (mut c Checker) struct_init(mut node ast.StructInit, is_field_zero_struct_ini
398398
}
399399
if type_sym.kind == .struct_ {
400400
info := type_sym.info as ast.Struct
401-
if info.attrs.len > 0 && info.attrs[0].name == 'noinit' && type_sym.mod != c.mod {
401+
if info.attrs.len > 0 && info.attrs.contains('noinit') && type_sym.mod != c.mod {
402402
c.error('struct `${type_sym.name}` is declared with a `[noinit]` attribute, so ' +
403403
'it cannot be initialized with `${type_sym.name}{}`', node.pos)
404404
}

0 commit comments

Comments
 (0)