We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent fa5950e commit 82f37bfCopy full SHA for 82f37bf
tests/micropython/native_closure.py
@@ -0,0 +1,32 @@
1
+# test native emitter can handle closures correctly
2
+
3
+# basic closure
4
+@micropython.native
5
+def f():
6
+ x = 1
7
+ @micropython.native
8
+ def g():
9
+ nonlocal x
10
+ return x
11
+ return g
12
+print(f()())
13
14
+# closing over an argument
15
16
+def f(x):
17
18
19
20
21
22
+print(f(2)())
23
24
+# closing over an argument and a normal local
25
26
27
+ y = 2 * x
28
29
+ def g(z):
30
+ return x + y + z
31
32
+print(f(2)(3))
tests/micropython/native_closure.py.exp
@@ -0,0 +1,3 @@
+1
+2
+9
0 commit comments