summaryrefslogtreecommitdiff
path: root/py/compile.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2018-09-15 12:41:25 +1000
committerDamien George <damien.p.george@gmail.com>2018-09-15 12:41:25 +1000
commit07caf4f969a9ad09e7a18d6cf419d92848908e40 (patch)
tree87152483487820754af6e882d8b34f90c1402419 /py/compile.c
parent1d7c221b3023d784ba96cb501b9becae794dac1f (diff)
py/emit: Remove need to call set_native_type to set viper return type.
Instead this return type is now stored in the scope_flags.
Diffstat (limited to 'py/compile.c')
-rw-r--r--py/compile.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/py/compile.c b/py/compile.c
index adf76fb97..2f6a9a326 100644
--- a/py/compile.c
+++ b/py/compile.c
@@ -2996,7 +2996,12 @@ STATIC void compile_scope(compiler_t *comp, scope_t *scope, pass_kind_t pass) {
// nodes[2] can be null or a test-expr
if (MP_PARSE_NODE_IS_ID(pn_annotation)) {
qstr ret_type = MP_PARSE_NODE_LEAF_ARG(pn_annotation);
- EMIT_ARG(set_native_type, MP_EMIT_NATIVE_TYPE_RETURN, 0, ret_type);
+ int native_type = mp_native_type_from_qstr(ret_type);
+ if (native_type < 0) {
+ comp->compile_error = mp_obj_new_exception_msg_varg(&mp_type_ViperTypeError, "unknown type '%q'", ret_type);
+ } else {
+ scope->scope_flags |= native_type << MP_SCOPE_FLAG_VIPERRET_POS;
+ }
} else {
compile_syntax_error(comp, pn_annotation, "return annotation must be an identifier");
}