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

checker: make the "unnecessary default" error a warning for now

This commit is contained in:
Alexander Medvednikov 2020-09-11 13:59:28 +02:00
parent 53bed596e7
commit 62a692b29c

View File

@ -370,17 +370,17 @@ pub fn (mut c Checker) struct_decl(decl ast.StructDecl) {
} }
if field.default_expr is ast.IntegerLiteral as lit { if field.default_expr is ast.IntegerLiteral as lit {
if lit.val == '0' { if lit.val == '0' {
c.error('unnecessary default value of `0`: struct fields are zeroed by default', c.warn('unnecessary default value of `0`: struct fields are zeroed by default',
lit.pos) lit.pos)
} }
} else if field.default_expr is ast.StringLiteral as lit { } else if field.default_expr is ast.StringLiteral as lit {
if lit.val == '' { if lit.val == '' {
c.error("unnecessary default value of '': struct fields are zeroed by default", c.warn("unnecessary default value of '': struct fields are zeroed by default",
lit.pos) lit.pos)
} }
} else if field.default_expr is ast.BoolLiteral as lit { } else if field.default_expr is ast.BoolLiteral as lit {
if lit.val == false { if lit.val == false {
c.error('unnecessary default value `false`: struct fields are zeroed by default', c.warn('unnecessary default value `false`: struct fields are zeroed by default',
lit.pos) lit.pos)
} }
} }