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

checker: fix [noinit] attr checking with multiple attr (#18079)

This commit is contained in:
Felipe Pena 2023-04-29 11:07:24 -03:00 committed by GitHub
parent e8df5a7861
commit e738d671a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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