Don't allow 'var x: T' for objects that require initialization
This commit is contained in:
parent
7652aede41
commit
05a0ec4adb
4 changed files with 63 additions and 37 deletions
|
|
@ -58,6 +58,24 @@ proc isArrayConstr(n: PNode): bool {.inline.} =
|
|||
result = n.kind == nkBracket and
|
||||
n.typ.skipTypes(abstractInst).kind == tyArray
|
||||
|
||||
type
|
||||
ObjConstrContext = object
|
||||
typ: PType # The constructed type
|
||||
initExpr: PNode # The init expression (nkObjConstr)
|
||||
requiresFullInit: bool # A `requiresInit` derived type will
|
||||
# set this to true while visiting
|
||||
# parent types.
|
||||
|
||||
InitStatus = enum # This indicates the result of object construction
|
||||
initUnknown
|
||||
initFull # All of the fields have been initialized
|
||||
initPartial # Some of the fields have been initialized
|
||||
initNone # None of the fields have been initialized
|
||||
initConflict # Fields from different branches have been initialized
|
||||
|
||||
proc semConstructType(c: PContext, initExpr: PNode,
|
||||
t: PType, flags: TExprFlags): InitStatus
|
||||
|
||||
template semIdeForTemplateOrGenericCheck(conf, n, requiresCheck) =
|
||||
# we check quickly if the node is where the cursor is
|
||||
when defined(nimsuggest):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue