diff options
author | Zahary Karadjov <zahary@gmail.com> | 2020-03-27 15:47:49 +0200 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2020-04-01 19:38:44 +0200 |
commit | a8b6222c862d207a32c104699fc4f0f0a8bced17 (patch) | |
tree | 73c3d36d385758386d6dc8d4e0c449e3fda783ff /compiler/semobjconstr.nim | |
parent | 216fd59c44c7eb56431748389e3b2116692189a1 (diff) | |
download | Nim-a8b6222c862d207a32c104699fc4f0f0a8bced17.tar.gz |
First steps, the compiler can boot with enforced requiresInit
Diffstat (limited to 'compiler/semobjconstr.nim')
-rw-r--r-- | compiler/semobjconstr.nim | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/compiler/semobjconstr.nim b/compiler/semobjconstr.nim index 489bc6684..bc1e85425 100644 --- a/compiler/semobjconstr.nim +++ b/compiler/semobjconstr.nim @@ -138,7 +138,7 @@ proc fieldsPresentInInitExpr(c: PContext, fieldsRecList, initExpr: PNode): strin proc missingMandatoryFields(c: PContext, fieldsRecList, initExpr: PNode): string = for r in directFieldsInRecList(fieldsRecList): - if {tfNotNil, tfNeedsInit} * r.sym.typ.flags != {}: + if {tfNotNil, tfRequiresInit} * r.sym.typ.flags != {}: let assignment = locateFieldInInitExpr(c, r.sym, initExpr) if assignment == nil: if result.len == 0: @@ -358,15 +358,10 @@ proc semObjConstr(c: PContext, n: PNode, flags: TExprFlags): PNode = # It's possible that the object was not fully initialized while # specifying a .requiresInit. pragma. - # XXX: Turn this into an error in the next release - if tfNeedsInit in t.flags and initResult != initFull: - # XXX: Disable this warning for now, because tfNeedsInit is propagated - # too aggressively from fields to object types (and this is not correct - # in case objects) - when false: message(n.info, warnUser, + if tfRequiresInit in t.flags and initResult != initFull: + localError(c.config, n.info, "object type uses the 'requiresInit' pragma, but not all fields " & - "have been initialized. future versions of Nim will treat this as " & - "an error") + "have been initialized.") # Since we were traversing the object fields, it's possible that # not all of the fields specified in the constructor was visited. |