From 6c485bc9dc5089f1e54067f5ef4ae84b05c7f0d6 Mon Sep 17 00:00:00 2001 From: ychenfo Date: Sat, 9 Apr 2022 03:50:39 +0800 Subject: [PATCH] nac3artiq: skip attribute writeback for option option types do not have any fields to be written back to the host so it is ok to skip. If we do not skip, there will be error when getting the value of it since it can be `none`, whose type is not concrete --- nac3artiq/src/codegen.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/nac3artiq/src/codegen.rs b/nac3artiq/src/codegen.rs index b63ee60c..809b7cc4 100644 --- a/nac3artiq/src/codegen.rs +++ b/nac3artiq/src/codegen.rs @@ -513,7 +513,9 @@ pub fn attributes_writeback<'ctx, 'a>( } let ty = ty.unwrap(); match &*ctx.unifier.get_ty(ty) { - TypeEnum::TObj { fields, .. } => { + TypeEnum::TObj { fields, obj_id, .. } + if *obj_id != ctx.primitives.option.get_obj_id(&ctx.unifier) => + { // we only care about primitive attributes // for non-primitive attributes, they should be in another global let mut attributes = Vec::new();