summaryrefslogtreecommitdiff
path: root/py/emitnative.c
diff options
context:
space:
mode:
authorDamien George <damien@micropython.org>2022-12-15 16:11:27 +1100
committerDamien George <damien@micropython.org>2022-12-16 11:44:10 +1100
commit910f5794037bc32a48a0bc2658305b571ad84362 (patch)
treef04f5a297cdfca49353832b7ccde184020be1763 /py/emitnative.c
parented58d6e4ce5878d5f53457e72686962e7f57f5df (diff)
py/emitnative: Initialise locals as Python object type for native code.
In @micropython.native code the types of variables and expressions are always Python objects, so they can be initialised as such. This prevents problems with compiling optimised code like while-loops where a local may be referenced before it is assigned to. Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'py/emitnative.c')
-rw-r--r--py/emitnative.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/py/emitnative.c b/py/emitnative.c
index 2d694983b..b02559ad7 100644
--- a/py/emitnative.c
+++ b/py/emitnative.c
@@ -401,7 +401,7 @@ STATIC void emit_native_start_pass(emit_t *emit, pass_kind_t pass, scope_t *scop
// local variables begin unbound, and have unknown type
for (mp_uint_t i = num_args; i < emit->local_vtype_alloc; i++) {
- emit->local_vtype[i] = VTYPE_UNBOUND;
+ emit->local_vtype[i] = emit->do_viper_types ? VTYPE_UNBOUND : VTYPE_PYOBJ;
}
// values on stack begin unbound