This commit is contained in:
ringabout
2025-10-13 21:26:35 +08:00
parent 934cf4caca
commit 7769d141b2
3 changed files with 2 additions and 58 deletions

View File

@@ -1131,7 +1131,7 @@ proc semForVars(c: PContext, n: PNode; flags: TExprFlags): PNode =
# BUGFIX: don't use `iter` here as that would strip away
# the ``tyGenericInst``! See ``tests/compile/tgeneric.nim``
# for an example:
v.typ = makeIterTupleType(c, iterBase)
v.typ = iterBase
n[0] = newSymNode(v)
if sfGenSym notin v.flags and not isDiscardUnderscore(v): addDecl(c, v)
elif v.owner == nil: setOwner(v, getCurrOwner(c))

View File

@@ -1787,23 +1787,6 @@ proc maybeAliasType(c: PContext; typeExpr, prev: PType): PType =
else:
result = nil
proc makeIterTupleType(c: PContext; typ: PType): PType =
if typ.kind == tyTuple:
var hasView = false
result = newTypeS(tyTuple, c)
for i in 0..<typ.len:
if typ[i].kind in {tyVar, tyLent}:
hasView = true
rawAddSon(result, typ[i].skipTypes({tyVar, tyLent}))
if hasView:
result.n = typ.n
else:
result = typ
else:
result = typ
proc fixupTypeOf(c: PContext, prev: PType, typ: PType) =
if prev != nil:
let result = newTypeS(tyAlias, c)
@@ -2038,9 +2021,6 @@ proc semTypeOf2(c: PContext; n: PNode; prev: PType): PType =
result = base
fixupTypeOf(c, prev, result)
if result.kind == tyTuple:
result = makeIterTupleType(c, result)
proc semTypeIdent(c: PContext, n: PNode): PSym =
if n.kind == nkSym:
result = getGenSym(c, n.sym)

View File

@@ -385,39 +385,6 @@ template assignTupleUnpacking(c: PTransf, e: PNode) =
let rhs = transform(c, newTupleAccess(c.graph, e, i))
result.add(asgnTo(lhs, rhs))
proc makeTupleUnpack(c: PTransf; lhs: PNode; rhs: PNode): PNode =
result = newNodeI(nkStmtList, lhs.info)
let temp = newSym(skTemp, getIdent(c.graph.cache, "tmpTupleAsgn"), c.idgen, getCurrOwner(c), rhs.info)
temp.typ = rhs.typ
temp.flags.incl(sfGenSym)
var v = newNodeI(nkLetSection, rhs.info)
let tempNode = newSymNode(temp) #newIdentNode(getIdent(genPrefix & $temp.id), value.info)
var vpart = newNodeI(nkIdentDefs, v.info, 3)
vpart[0] = tempNode
vpart[1] = c.graph.emptyNode
vpart[2] = rhs
v.add vpart
result.add(v)
var tupleConstr = newNodeIT(nkTupleConstr, lhs.info, lhs.typ)
for i in 0..<rhs.typ.len:
var field: PNode = nil
if rhs.typ[i].kind in {tyVar, tyLent}:
let tupleType = newTupleAccessRaw(tempNode, i)
tupleType.typ() = rhs.typ[i]
field = newDeref(tupleType)
else:
field = newTupleAccessRaw(tempNode, i)
field.typ() = rhs.typ[i].skipTypes({tyVar, tyLent})
tupleConstr.add field
result.add newAsgnStmt(c, nkFastAsgn, lhs, tupleConstr, false)
result = transform(c, result)
proc hasViewTypes(typ: PType): bool =
if typ.kind == tyTuple:
result = false
@@ -435,10 +402,7 @@ proc transformYield(c: PTransf, n: PNode): PNode =
case lhs.kind
of nkSym:
internalAssert c.graph.config, lhs.sym.kind == skForVar
if rhs.typ.kind == tyTuple and hasViewTypes(rhs.typ):
result = makeTupleUnpack(c, lhs, rhs)
else:
result = newAsgnStmt(c, nkFastAsgn, lhs, rhs, false)
result = newAsgnStmt(c, nkFastAsgn, lhs, rhs, false)
of nkDotExpr:
result = newAsgnStmt(c, nkAsgn, lhs, rhs, false)
else: