Plug another hole: default(T) forbidden for objects requiring initialization

This commit is contained in:
Zahary Karadjov 2020-03-27 20:53:09 +02:00 • committed by Andreas Rumpf
commit 8ae48292ff
5 changed files with 31 additions and 19 deletions

View file

@ -616,7 +616,7 @@ proc semVarOrLet(c: PContext, n: PNode, symkind: TSymKind): PNode =
b[j] = newSymNode(v)
if def.kind == nkEmpty:
if v.typ.kind in {tyObject, tyTuple}:
discard semConstructType(c, newNodeI(nkObjConstr, v.info), v.typ, {})
checkDefaultConstruction(c, v.typ, v.info)
else:
checkNilable(c, v)
if sfCompileTime in v.flags: