From 9ff0333a4ccffb253f03fc113d086bbc81b566e9 Mon Sep 17 00:00:00 2001 From: ringabout <43030857+ringabout@users.noreply.github.com> Date: Mon, 9 Sep 2024 17:22:37 +0800 Subject: [PATCH] fixes #21353; fixes default closure in the VM (#24070) fixes #21353 ```nim result = newNodeIT(nkTupleConstr, info, t) result.add(newNodeIT(nkNilLit, info, t)) result.add(newNodeIT(nkNilLit, info, t)) ``` The old implementation uses `t` which is the type of the closure function as its type. It is not correct and generates ((nil, nil), (nil, nil)) for `default(closures)`. This PR creates `(tyPointer, tyPointer)` for fake closure types just like what cctypes do. --- compiler/vm.nim | 12 ++++++------ compiler/vmgen.nim | 34 +++++++++++++++++----------------- tests/vm/tvmmisc.nim | 4 ++++ 3 files changed, 27 insertions(+), 23 deletions(-) diff --git a/compiler/vm.nim b/compiler/vm.nim index a9a25e4ea5..ce14a9496e 100644 --- a/compiler/vm.nim +++ b/compiler/vm.nim @@ -507,7 +507,7 @@ proc setLenSeq(c: PCtx; node: PNode; newLen: int; info: TLineInfo) = setLen(node.sons, newLen) if oldLen < newLen: for i in oldLen..