-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Yielding from var fails with pairs and destructuring #24033
Labels
Comments
!nim c type Query = ref object
iterator pairs(query: Query): (int, (string, float32)) =
var output: (int, (string, float32)) = (0, ("foo", 3.14))
for id in @[ 0, 1, 2 ]:
output[0] = id
yield output
for id, (str, num) in Query():
discard |
🐧 Linux bisect by @juancarlospaco (collaborator)devel 👎 FAILOutput
IRCompiled filesize0 (0 bytes)
Stats
ASTnnkStmtList.newTree(
nnkTypeSection.newTree(
nnkTypeDef.newTree(
newIdentNode("Query"),
newEmptyNode(),
nnkRefTy.newTree(
nnkObjectTy.newTree(
newEmptyNode(),
newEmptyNode(),
newEmptyNode()
)
)
)
),
nnkIteratorDef.newTree(
newIdentNode("pairs"),
newEmptyNode(),
newEmptyNode(),
nnkFormalParams.newTree(
nnkTupleConstr.newTree(
newIdentNode("int"),
nnkTupleConstr.newTree(
newIdentNode("string"),
newIdentNode("float32")
)
),
nnkIdentDefs.newTree(
newIdentNode("query"),
newIdentNode("Query"),
newEmptyNode()
)
),
newEmptyNode(),
newEmptyNode(),
nnkStmtList.newTree(
nnkVarSection.newTree(
nnkIdentDefs.newTree(
newIdentNode("output"),
nnkTupleConstr.newTree(
newIdentNode("int"),
nnkTupleConstr.newTree(
newIdentNode("string"),
newIdentNode("float32")
)
),
nnkTupleConstr.newTree(
newLit(0),
nnkTupleConstr.newTree(
newLit("foo"),
newLit(3.14)
)
)
)
),
nnkForStmt.newTree(
newIdentNode("id"),
nnkPrefix.newTree(
newIdentNode("@"),
nnkBracket.newTree(
newLit(0),
newLit(1),
newLit(2)
)
),
nnkStmtList.newTree(
nnkAsgn.newTree(
nnkBracketExpr.newTree(
newIdentNode("output"),
newLit(0)
),
newIdentNode("id")
),
nnkYieldStmt.newTree(
newIdentNode("output")
)
)
)
)
),
nnkForStmt.newTree(
newIdentNode("id"),
nnkVarTuple.newTree(
newIdentNode("str"),
newIdentNode("num"),
newEmptyNode()
),
nnkCall.newTree(
newIdentNode("Query")
),
nnkStmtList.newTree(
nnkDiscardStmt.newTree(
newEmptyNode()
)
)
)
) stable 👎 FAILOutput
IRCompiled filesize0 (0 bytes)
Stats
ASTnnkStmtList.newTree(
nnkTypeSection.newTree(
nnkTypeDef.newTree(
newIdentNode("Query"),
newEmptyNode(),
nnkRefTy.newTree(
nnkObjectTy.newTree(
newEmptyNode(),
newEmptyNode(),
newEmptyNode()
)
)
)
),
nnkIteratorDef.newTree(
newIdentNode("pairs"),
newEmptyNode(),
newEmptyNode(),
nnkFormalParams.newTree(
nnkTupleConstr.newTree(
newIdentNode("int"),
nnkTupleConstr.newTree(
newIdentNode("string"),
newIdentNode("float32")
)
),
nnkIdentDefs.newTree(
newIdentNode("query"),
newIdentNode("Query"),
newEmptyNode()
)
),
newEmptyNode(),
newEmptyNode(),
nnkStmtList.newTree(
nnkVarSection.newTree(
nnkIdentDefs.newTree(
newIdentNode("output"),
nnkTupleConstr.newTree(
newIdentNode("int"),
nnkTupleConstr.newTree(
newIdentNode("string"),
newIdentNode("float32")
)
),
nnkTupleConstr.newTree(
newLit(0),
nnkTupleConstr.newTree(
newLit("foo"),
newLit(3.14)
)
)
)
),
nnkForStmt.newTree(
newIdentNode("id"),
nnkPrefix.newTree(
newIdentNode("@"),
nnkBracket.newTree(
newLit(0),
newLit(1),
newLit(2)
)
),
nnkStmtList.newTree(
nnkAsgn.newTree(
nnkBracketExpr.newTree(
newIdentNode("output"),
newLit(0)
),
newIdentNode("id")
),
nnkYieldStmt.newTree(
newIdentNode("output")
)
)
)
)
),
nnkForStmt.newTree(
newIdentNode("id"),
nnkVarTuple.newTree(
newIdentNode("str"),
newIdentNode("num"),
newEmptyNode()
),
nnkCall.newTree(
newIdentNode("Query")
),
nnkStmtList.newTree(
nnkDiscardStmt.newTree(
newEmptyNode()
)
)
)
) 2.0.8 👎 FAILOutput
IRCompiled filesize0 (0 bytes)
Stats
ASTnnkStmtList.newTree(
nnkTypeSection.newTree(
nnkTypeDef.newTree(
newIdentNode("Query"),
newEmptyNode(),
nnkRefTy.newTree(
nnkObjectTy.newTree(
newEmptyNode(),
newEmptyNode(),
newEmptyNode()
)
)
)
),
nnkIteratorDef.newTree(
newIdentNode("pairs"),
newEmptyNode(),
newEmptyNode(),
nnkFormalParams.newTree(
nnkTupleConstr.newTree(
newIdentNode("int"),
nnkTupleConstr.newTree(
newIdentNode("string"),
newIdentNode("float32")
)
),
nnkIdentDefs.newTree(
newIdentNode("query"),
newIdentNode("Query"),
newEmptyNode()
)
),
newEmptyNode(),
newEmptyNode(),
nnkStmtList.newTree(
nnkVarSection.newTree(
nnkIdentDefs.newTree(
newIdentNode("output"),
nnkTupleConstr.newTree(
newIdentNode("int"),
nnkTupleConstr.newTree(
newIdentNode("string"),
newIdentNode("float32")
)
),
nnkTupleConstr.newTree(
newLit(0),
nnkTupleConstr.newTree(
newLit("foo"),
newLit(3.14)
)
)
)
),
nnkForStmt.newTree(
newIdentNode("id"),
nnkPrefix.newTree(
newIdentNode("@"),
nnkBracket.newTree(
newLit(0),
newLit(1),
newLit(2)
)
),
nnkStmtList.newTree(
nnkAsgn.newTree(
nnkBracketExpr.newTree(
newIdentNode("output"),
newLit(0)
),
newIdentNode("id")
),
nnkYieldStmt.newTree(
newIdentNode("output")
)
)
)
)
),
nnkForStmt.newTree(
newIdentNode("id"),
nnkVarTuple.newTree(
newIdentNode("str"),
newIdentNode("num"),
newEmptyNode()
),
nnkCall.newTree(
newIdentNode("Query")
),
nnkStmtList.newTree(
nnkDiscardStmt.newTree(
newEmptyNode()
)
)
)
) 2.0.0 👎 FAILOutput
IRCompiled filesize0 (0 bytes)
Stats
ASTnnkStmtList.newTree(
nnkTypeSection.newTree(
nnkTypeDef.newTree(
newIdentNode("Query"),
newEmptyNode(),
nnkRefTy.newTree(
nnkObjectTy.newTree(
newEmptyNode(),
newEmptyNode(),
newEmptyNode()
)
)
)
),
nnkIteratorDef.newTree(
newIdentNode("pairs"),
newEmptyNode(),
newEmptyNode(),
nnkFormalParams.newTree(
nnkTupleConstr.newTree(
newIdentNode("int"),
nnkTupleConstr.newTree(
newIdentNode("string"),
newIdentNode("float32")
)
),
nnkIdentDefs.newTree(
newIdentNode("query"),
newIdentNode("Query"),
newEmptyNode()
)
),
newEmptyNode(),
newEmptyNode(),
nnkStmtList.newTree(
nnkVarSection.newTree(
nnkIdentDefs.newTree(
newIdentNode("output"),
nnkTupleConstr.newTree(
newIdentNode("int"),
nnkTupleConstr.newTree(
newIdentNode("string"),
newIdentNode("float32")
)
),
nnkTupleConstr.newTree(
newLit(0),
nnkTupleConstr.newTree(
newLit("foo"),
newLit(3.14)
)
)
)
),
nnkForStmt.newTree(
newIdentNode("id"),
nnkPrefix.newTree(
newIdentNode("@"),
nnkBracket.newTree(
newLit(0),
newLit(1),
newLit(2)
)
),
nnkStmtList.newTree(
nnkAsgn.newTree(
nnkBracketExpr.newTree(
newIdentNode("output"),
newLit(0)
),
newIdentNode("id")
),
nnkYieldStmt.newTree(
newIdentNode("output")
)
)
)
)
),
nnkForStmt.newTree(
newIdentNode("id"),
nnkVarTuple.newTree(
newIdentNode("str"),
newIdentNode("num"),
newEmptyNode()
),
nnkCall.newTree(
newIdentNode("Query")
),
nnkStmtList.newTree(
nnkDiscardStmt.newTree(
newEmptyNode()
)
)
)
) 1.6.20 👎 FAILOutput
IRCompiled filesize0 (0 bytes)
Stats
ASTnnkStmtList.newTree(
nnkTypeSection.newTree(
nnkTypeDef.newTree(
newIdentNode("Query"),
newEmptyNode(),
nnkRefTy.newTree(
nnkObjectTy.newTree(
newEmptyNode(),
newEmptyNode(),
newEmptyNode()
)
)
)
),
nnkIteratorDef.newTree(
newIdentNode("pairs"),
newEmptyNode(),
newEmptyNode(),
nnkFormalParams.newTree(
nnkTupleConstr.newTree(
newIdentNode("int"),
nnkTupleConstr.newTree(
newIdentNode("string"),
newIdentNode("float32")
)
),
nnkIdentDefs.newTree(
newIdentNode("query"),
newIdentNode("Query"),
newEmptyNode()
)
),
newEmptyNode(),
newEmptyNode(),
nnkStmtList.newTree(
nnkVarSection.newTree(
nnkIdentDefs.newTree(
newIdentNode("output"),
nnkTupleConstr.newTree(
newIdentNode("int"),
nnkTupleConstr.newTree(
newIdentNode("string"),
newIdentNode("float32")
)
),
nnkTupleConstr.newTree(
newLit(0),
nnkTupleConstr.newTree(
newLit("foo"),
newLit(3.14)
)
)
)
),
nnkForStmt.newTree(
newIdentNode("id"),
nnkPrefix.newTree(
newIdentNode("@"),
nnkBracket.newTree(
newLit(0),
newLit(1),
newLit(2)
)
),
nnkStmtList.newTree(
nnkAsgn.newTree(
nnkBracketExpr.newTree(
newIdentNode("output"),
newLit(0)
),
newIdentNode("id")
),
nnkYieldStmt.newTree(
newIdentNode("output")
)
)
)
)
),
nnkForStmt.newTree(
newIdentNode("id"),
nnkVarTuple.newTree(
newIdentNode("str"),
newIdentNode("num"),
newEmptyNode()
),
nnkCall.newTree(
newIdentNode("Query")
),
nnkStmtList.newTree(
nnkDiscardStmt.newTree(
newEmptyNode()
)
)
)
) 1.4.8 👎 FAILOutput
IRCompiled filesize0 (0 bytes)
Stats
ASTnnkStmtList.newTree(
nnkTypeSection.newTree(
nnkTypeDef.newTree(
newIdentNode("Query"),
newEmptyNode(),
nnkRefTy.newTree(
nnkObjectTy.newTree(
newEmptyNode(),
newEmptyNode(),
newEmptyNode()
)
)
)
),
nnkIteratorDef.newTree(
newIdentNode("pairs"),
newEmptyNode(),
newEmptyNode(),
nnkFormalParams.newTree(
nnkPar.newTree(
newIdentNode("int"),
nnkPar.newTree(
newIdentNode("string"),
newIdentNode("float32")
)
),
nnkIdentDefs.newTree(
newIdentNode("query"),
newIdentNode("Query"),
newEmptyNode()
)
),
newEmptyNode(),
newEmptyNode(),
nnkStmtList.newTree(
nnkVarSection.newTree(
nnkIdentDefs.newTree(
newIdentNode("output"),
nnkPar.newTree(
newIdentNode("int"),
nnkPar.newTree(
newIdentNode("string"),
newIdentNode("float32")
)
),
nnkPar.newTree(
newLit(0),
nnkPar.newTree(
newLit("foo"),
newLit(3.14)
)
)
)
),
nnkForStmt.newTree(
newIdentNode("id"),
nnkPrefix.newTree(
newIdentNode("@"),
nnkBracket.newTree(
newLit(0),
newLit(1),
newLit(2)
)
),
nnkStmtList.newTree(
nnkAsgn.newTree(
nnkBracketExpr.newTree(
newIdentNode("output"),
newLit(0)
),
newIdentNode("id")
),
nnkYieldStmt.newTree(
newIdentNode("output")
)
)
)
)
),
nnkForStmt.newTree(
newIdentNode("id"),
nnkVarTuple.newTree(
newIdentNode("str"),
newIdentNode("num"),
newEmptyNode()
),
nnkCall.newTree(
newIdentNode("Query")
),
nnkStmtList.newTree(
nnkDiscardStmt.newTree(
newEmptyNode()
)
)
)
) 1.2.18 👎 FAILOutput
IRCompiled filesize0 (0 bytes)
Stats
ASTnnkStmtList.newTree(
nnkTypeSection.newTree(
nnkTypeDef.newTree(
newIdentNode("Query"),
newEmptyNode(),
nnkRefTy.newTree(
nnkObjectTy.newTree(
newEmptyNode(),
newEmptyNode(),
newEmptyNode()
)
)
)
),
nnkIteratorDef.newTree(
newIdentNode("pairs"),
newEmptyNode(),
newEmptyNode(),
nnkFormalParams.newTree(
nnkPar.newTree(
newIdentNode("int"),
nnkPar.newTree(
newIdentNode("string"),
newIdentNode("float32")
)
),
nnkIdentDefs.newTree(
newIdentNode("query"),
newIdentNode("Query"),
newEmptyNode()
)
),
newEmptyNode(),
newEmptyNode(),
nnkStmtList.newTree(
nnkVarSection.newTree(
nnkIdentDefs.newTree(
newIdentNode("output"),
nnkPar.newTree(
newIdentNode("int"),
nnkPar.newTree(
newIdentNode("string"),
newIdentNode("float32")
)
),
nnkPar.newTree(
newLit(0),
nnkPar.newTree(
newLit("foo"),
newLit(3.14)
)
)
)
),
nnkForStmt.newTree(
newIdentNode("id"),
nnkPrefix.newTree(
newIdentNode("@"),
nnkBracket.newTree(
newLit(0),
newLit(1),
newLit(2)
)
),
nnkStmtList.newTree(
nnkAsgn.newTree(
nnkBracketExpr.newTree(
newIdentNode("output"),
newLit(0)
),
newIdentNode("id")
),
nnkYieldStmt.newTree(
newIdentNode("output")
)
)
)
)
),
nnkForStmt.newTree(
newIdentNode("id"),
nnkVarTuple.newTree(
newIdentNode("str"),
newIdentNode("num"),
newEmptyNode()
),
nnkCall.newTree(
newIdentNode("Query")
),
nnkStmtList.newTree(
nnkDiscardStmt.newTree(
newEmptyNode()
)
)
)
) 1.0.10 👎 FAILOutput
IRCompiled filesize0 (0 bytes)
Stats
ASTnnkStmtList.newTree(
nnkTypeSection.newTree(
nnkTypeDef.newTree(
newIdentNode("Query"),
newEmptyNode(),
nnkRefTy.newTree(
nnkObjectTy.newTree(
newEmptyNode(),
newEmptyNode(),
newEmptyNode()
)
)
)
),
nnkIteratorDef.newTree(
newIdentNode("pairs"),
newEmptyNode(),
newEmptyNode(),
nnkFormalParams.newTree(
nnkPar.newTree(
newIdentNode("int"),
nnkPar.newTree(
newIdentNode("string"),
newIdentNode("float32")
)
),
nnkIdentDefs.newTree(
newIdentNode("query"),
newIdentNode("Query"),
newEmptyNode()
)
),
newEmptyNode(),
newEmptyNode(),
nnkStmtList.newTree(
nnkVarSection.newTree(
nnkIdentDefs.newTree(
newIdentNode("output"),
nnkPar.newTree(
newIdentNode("int"),
nnkPar.newTree(
newIdentNode("string"),
newIdentNode("float32")
)
),
nnkPar.newTree(
newLit(0),
nnkPar.newTree(
newLit("foo"),
newLit(3.14)
)
)
)
),
nnkForStmt.newTree(
newIdentNode("id"),
nnkPrefix.newTree(
newIdentNode("@"),
nnkBracket.newTree(
newLit(0),
newLit(1),
newLit(2)
)
),
nnkStmtList.newTree(
nnkAsgn.newTree(
nnkBracketExpr.newTree(
newIdentNode("output"),
newLit(0)
),
newIdentNode("id")
),
nnkYieldStmt.newTree(
newIdentNode("output")
)
)
)
)
),
nnkForStmt.newTree(
newIdentNode("id"),
nnkVarTuple.newTree(
newIdentNode("str"),
newIdentNode("num"),
newEmptyNode()
),
nnkCall.newTree(
newIdentNode("Query")
),
nnkStmtList.newTree(
nnkDiscardStmt.newTree(
newEmptyNode()
)
)
)
) Stats
🤖 Bug found in |
Might be worth mentioning a similar bug I reported here: #23454 |
Unpacking the tuple with for a in Query().pairs:
let (id, (str, num)) = a |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Description
I expect the following code to compile:
Nim Version
Current Output
Known Workarounds
This works:
Additional Information
No response
The text was updated successfully, but these errors were encountered: