fixes #20740; fixes pre-existing field visibility issues and removes efSkipFieldVisibilityCheck (#20741)
fixes #20740 pre-existing field visibility and refactoring
This commit is contained in:
parent
6b1e353aa1
commit
c4e5dab419
5 changed files with 28 additions and 11 deletions
|
|
@ -76,8 +76,7 @@ proc semConstrField(c: PContext, flags: TExprFlags,
|
|||
let assignment = locateFieldInInitExpr(c, field, initExpr)
|
||||
if assignment != nil:
|
||||
if nfSem in assignment.flags: return assignment[1]
|
||||
if nfUseDefaultField in assignment[1].flags or
|
||||
efSkipFieldVisibilityCheck in flags:
|
||||
if nfUseDefaultField in assignment[1].flags:
|
||||
discard
|
||||
elif not fieldVisible(c, field):
|
||||
localError(c.config, initExpr.info,
|
||||
|
|
@ -416,10 +415,7 @@ proc semObjConstr(c: PContext, n: PNode, flags: TExprFlags; expectedType: PType
|
|||
# field (if this is a case object, initialized fields in two different
|
||||
# branches will be reported as an error):
|
||||
var constrCtx = initConstrContext(t, result)
|
||||
let (initResult, defaults) = if nfUseDefaultField in n.flags:
|
||||
semConstructTypeAux(c, constrCtx, flags + {efSkipFieldVisibilityCheck})
|
||||
else:
|
||||
semConstructTypeAux(c, constrCtx, flags)
|
||||
let (initResult, defaults) = semConstructTypeAux(c, constrCtx, flags)
|
||||
result[0].sons.add defaults
|
||||
var hasError = false # needed to split error detect/report for better msgs
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue