Turn the warning for uninitialized (result) variables into errors

This commit is contained in:
Zahary Karadjov 2020-03-29 02:06:39 +02:00 • committed by Andreas Rumpf
commit 1b570f2b18
7 changed files with 103 additions and 17 deletions

View file

@ -146,8 +146,9 @@ proc fieldsPresentInInitExpr(c: PContext, fieldsRecList, initExpr: PNode): strin
proc missingMandatoryFields(c: PContext, fieldsRecList: PNode,
constrCtx: ObjConstrContext): string =
for r in directFieldsInRecList(fieldsRecList):
if constrCtx.requiresFullInit or sfRequiresInit in r.sym.flags or
{tfNotNil, tfRequiresInit, tfHasRequiresInit} * r.sym.typ.flags != {}:
if constrCtx.requiresFullInit or
sfRequiresInit in r.sym.flags or
r.sym.typ.requiresInit:
let assignment = locateFieldInInitExpr(c, r.sym, constrCtx.initExpr)
if assignment == nil:
if result.len == 0: