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: 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. --- tests/vm/tvmmisc.nim | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'tests') diff --git a/tests/vm/tvmmisc.nim b/tests/vm/tvmmisc.nim index 6160702ad..6aeac5529 100644 --- a/tests/vm/tvmmisc.nim +++ b/tests/vm/tvmmisc.nim @@ -790,3 +790,7 @@ block: # bug #23925 static: bar() bar() + +static: # bug #21353 + var s: proc () = default(proc ()) + doAssert s == nil -- cgit 1.4.1-2-gfad0