refactoring: removed dead code (#18567)

This commit is contained in:
Andreas Rumpf 2021-07-24 00:30:02 +02:00 • committed by GitHub
commit f4ff276a90
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 17 deletions

View file

@ -65,7 +65,7 @@ type
# you may be in position to supply a better error message # you may be in position to supply a better error message
# to the user. # to the user.
efWantStmt, efAllowStmt, efDetermineType, efExplain, efWantStmt, efAllowStmt, efDetermineType, efExplain,
efAllowDestructor, efWantValue, efOperand, efNoSemCheck, efWantValue, efOperand, efNoSemCheck,
efNoEvaluateGeneric, efInCall, efFromHlo, efNoSem2Check, efNoEvaluateGeneric, efInCall, efFromHlo, efNoSem2Check,
efNoUndeclared efNoUndeclared
# Use this if undeclared identifiers should not raise an error during # Use this if undeclared identifiers should not raise an error during

View file

@ -623,10 +623,10 @@ proc semArrayConstr(c: PContext, n: PNode, flags: TExprFlags): PNode =
localError(c.config, x.info, "invalid order in array constructor") localError(c.config, x.info, "invalid order in array constructor")
x = x[1] x = x[1]
let xx = semExprWithType(c, x, flags*{efAllowDestructor}) let xx = semExprWithType(c, x, {})
result.add xx result.add xx
typ = commonType(c, typ, xx.typ) typ = commonType(c, typ, xx.typ)
#n[i] = semExprWithType(c, x, flags*{efAllowDestructor}) #n[i] = semExprWithType(c, x, {})
#result.add fitNode(c, typ, n[i]) #result.add fitNode(c, typ, n[i])
inc(lastIndex) inc(lastIndex)
addSonSkipIntLit(result.typ, typ, c.idgen) addSonSkipIntLit(result.typ, typ, c.idgen)
@ -1758,13 +1758,9 @@ proc semAsgn(c: PContext, n: PNode; mode=asgnNormal): PNode =
localError(c.config, a.info, errXCannotBeAssignedTo % localError(c.config, a.info, errXCannotBeAssignedTo %
renderTree(a, {renderNoComments})) renderTree(a, {renderNoComments}))
else: else:
let let lhs = n[0]
lhs = n[0] let rhs = semExprWithType(c, n[1], {})
lhsIsResult = lhs.kind == nkSym and lhs.sym.kind == skResult if lhs.kind == nkSym and lhs.sym.kind == skResult:
var
rhs = semExprWithType(c, n[1],
if lhsIsResult: {efAllowDestructor} else: {})
if lhsIsResult:
n.typ = c.enforceVoidContext n.typ = c.enforceVoidContext
if c.p.owner.kind != skMacro and resultTypeIsInferrable(lhs.sym.typ): if c.p.owner.kind != skMacro and resultTypeIsInferrable(lhs.sym.typ):
var rhsTyp = rhs.typ var rhsTyp = rhs.typ
@ -2512,8 +2508,7 @@ proc semTupleFieldsConstr(c: PContext, n: PNode, flags: TExprFlags): PNode =
let id = considerQuotedIdent(c, n[i][0]) let id = considerQuotedIdent(c, n[i][0])
if containsOrIncl(ids, id.id): if containsOrIncl(ids, id.id):
localError(c.config, n[i].info, errFieldInitTwice % id.s) localError(c.config, n[i].info, errFieldInitTwice % id.s)
n[i][1] = semExprWithType(c, n[i][1], n[i][1] = semExprWithType(c, n[i][1], {})
flags*{efAllowDestructor})
if n[i][1].typ.kind == tyTypeDesc: if n[i][1].typ.kind == tyTypeDesc:
localError(c.config, n[i][1].info, "typedesc not allowed as tuple field.") localError(c.config, n[i][1].info, "typedesc not allowed as tuple field.")
@ -2533,7 +2528,7 @@ proc semTuplePositionsConstr(c: PContext, n: PNode, flags: TExprFlags): PNode =
result.transitionSonsKind(nkTupleConstr) result.transitionSonsKind(nkTupleConstr)
var typ = newTypeS(tyTuple, c) # leave typ.n nil! var typ = newTypeS(tyTuple, c) # leave typ.n nil!
for i in 0..<n.len: for i in 0..<n.len:
n[i] = semExprWithType(c, n[i], flags*{efAllowDestructor}) n[i] = semExprWithType(c, n[i], {})
addSonSkipIntLit(typ, n[i].typ, c.idgen) addSonSkipIntLit(typ, n[i].typ, c.idgen)
result.typ = typ result.typ = typ

View file

@ -222,8 +222,7 @@ proc semConstructFields(c: PContext, n: PNode,
valsDiff.renderAsType(n[0].typ)]) valsDiff.renderAsType(n[0].typ)])
let branchNode = n[selectedBranch] let branchNode = n[selectedBranch]
let flags = flags*{efAllowDestructor} + {efPreferStatic, let flags = {efPreferStatic, efPreferNilResult}
efPreferNilResult}
var discriminatorVal = semConstrField(c, flags, var discriminatorVal = semConstrField(c, flags,
discriminator.sym, discriminator.sym,
constrCtx.initExpr) constrCtx.initExpr)
@ -436,6 +435,6 @@ proc semObjConstr(c: PContext, n: PNode, flags: TExprFlags): PNode =
if initResult == initFull: if initResult == initFull:
incl result.flags, nfAllFieldsSet incl result.flags, nfAllFieldsSet
# wrap in an error see #17437 # wrap in an error see #17437
if hasError: result = errorNode(c, result) if hasError: result = errorNode(c, result)

View file

@ -512,7 +512,7 @@ proc semVarOrLet(c: PContext, n: PNode, symkind: TSymKind): PNode =
var def: PNode = c.graph.emptyNode var def: PNode = c.graph.emptyNode
if a[^1].kind != nkEmpty: if a[^1].kind != nkEmpty:
def = semExprWithType(c, a[^1], {efAllowDestructor}) def = semExprWithType(c, a[^1], {})
if def.kind == nkSym and def.sym.kind in {skTemplate, skMacro}: if def.kind == nkSym and def.sym.kind in {skTemplate, skMacro}:
typFlags.incl taIsTemplateOrMacro typFlags.incl taIsTemplateOrMacro